From 10e8aa9af170886266618370e2ef330e0b2055bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Sat, 4 May 2013 22:21:38 +0200 Subject: [PATCH 1/7] ASoC: fix kernel message grepability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Mirosław Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 77 +++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d56bbea6e75e..308895a438d6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -272,8 +272,8 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec) codec->debugfs_codec_root = debugfs_create_dir(codec->name, debugfs_card_root); if (!codec->debugfs_codec_root) { - dev_warn(codec->dev, "ASoC: Failed to create codec debugfs" - " directory\n"); + dev_warn(codec->dev, + "ASoC: Failed to create codec debugfs directory\n"); return; } @@ -286,8 +286,8 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec) codec->debugfs_codec_root, codec, &codec_reg_fops); if (!codec->debugfs_reg) - dev_warn(codec->dev, "ASoC: Failed to create codec register" - " debugfs file\n"); + dev_warn(codec->dev, + "ASoC: Failed to create codec register debugfs file\n"); snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root); } @@ -631,8 +631,7 @@ int snd_soc_suspend(struct device *dev) */ if (codec->dapm.idle_bias_off) { dev_dbg(codec->dev, - "ASoC: idle_bias_off CODEC on" - " over suspend\n"); + "ASoC: idle_bias_off CODEC on over suspend\n"); break; } case SND_SOC_BIAS_OFF: @@ -643,8 +642,8 @@ int snd_soc_suspend(struct device *dev) regcache_mark_dirty(codec->control_data); break; default: - dev_dbg(codec->dev, "ASoC: CODEC is on" - " over suspend\n"); + dev_dbg(codec->dev, + "ASoC: CODEC is on over suspend\n"); break; } } @@ -713,8 +712,8 @@ static void soc_resume_deferred(struct work_struct *work) codec->suspended = 0; break; default: - dev_dbg(codec->dev, "ASoC: CODEC was on over" - " suspend\n"); + dev_dbg(codec->dev, + "ASoC: CODEC was on over suspend\n"); break; } } @@ -1110,8 +1109,8 @@ static int soc_probe_codec(struct snd_soc_card *card, } WARN(codec->dapm.idle_bias_off && codec->dapm.bias_level != SND_SOC_BIAS_OFF, - "codec %s can not start from non-off bias" - " with idle_bias_off==1\n", codec->name); + "codec %s can not start from non-off bias with idle_bias_off==1\n", + codec->name); } /* If the driver didn't set I/O up try regmap */ @@ -1582,8 +1581,9 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec, codec->compress_type = compress_type; ret = snd_soc_cache_init(codec); if (ret < 0) { - dev_err(codec->dev, "ASoC: Failed to set cache compression" - " type: %d\n", ret); + dev_err(codec->dev, + "ASoC: Failed to set cache compression type: %d\n", + ret); return ret; } codec->cache_init = 1; @@ -1639,8 +1639,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, card->owner, 0, &card->snd_card); if (ret < 0) { - dev_err(card->dev, "ASoC: can't create sound card for" - " card %s: %d\n", card->name, ret); + dev_err(card->dev, + "ASoC: can't create sound card for card %s: %d\n", + card->name, ret); goto base_error; } card->snd_card->dev = card->dev; @@ -1815,8 +1816,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) for (i = 0; i < card->num_rtd; i++) { ret = soc_register_ac97_dai_link(&card->rtd[i]); if (ret < 0) { - dev_err(card->dev, "ASoC: failed to register AC97:" - " %d\n", ret); + dev_err(card->dev, + "ASoC: failed to register AC97: %d\n", ret); while (--i >= 0) soc_unregister_ac97_dai_link(card->rtd[i].codec); goto probe_aux_dev_err; @@ -3586,14 +3587,16 @@ int snd_soc_register_card(struct snd_soc_card *card) * not both or neither. */ if (!!link->codec_name == !!link->codec_of_node) { - dev_err(card->dev, "ASoC: Neither/both codec" - " name/of_node are set for %s\n", link->name); + dev_err(card->dev, + "ASoC: Neither/both codec name/of_node are set for %s\n", + link->name); return -EINVAL; } /* Codec DAI name must be specified */ if (!link->codec_dai_name) { - dev_err(card->dev, "ASoC: codec_dai_name not" - " set for %s\n", link->name); + dev_err(card->dev, + "ASoC: codec_dai_name not set for %s\n", + link->name); return -EINVAL; } @@ -3602,8 +3605,9 @@ int snd_soc_register_card(struct snd_soc_card *card) * can be left unspecified, and a dummy platform will be used. */ if (link->platform_name && link->platform_of_node) { - dev_err(card->dev, "ASoC: Both platform name/of_node" - " are set for %s\n", link->name); + dev_err(card->dev, + "ASoC: Both platform name/of_node are set for %s\n", + link->name); return -EINVAL; } @@ -3613,8 +3617,9 @@ int snd_soc_register_card(struct snd_soc_card *card) * name alone.. */ if (link->cpu_name && link->cpu_of_node) { - dev_err(card->dev, "ASoC: Neither/both " - "cpu name/of_node are set for %s\n",link->name); + dev_err(card->dev, + "ASoC: Neither/both cpu name/of_node are set for %s\n", + link->name); return -EINVAL; } /* @@ -3623,8 +3628,9 @@ int snd_soc_register_card(struct snd_soc_card *card) */ if (!link->cpu_dai_name && !(link->cpu_name || link->cpu_of_node)) { - dev_err(card->dev, "ASoC: Neither cpu_dai_name nor " - "cpu_name/of_node are set for %s\n", link->name); + dev_err(card->dev, + "ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for %s\n", + link->name); return -EINVAL; } } @@ -3728,8 +3734,9 @@ static inline char *fmt_multiple_name(struct device *dev, struct snd_soc_dai_driver *dai_drv) { if (dai_drv->name == NULL) { - dev_err(dev, "ASoC: error - multiple DAI %s registered with" - " no name\n", dev_name(dev)); + dev_err(dev, + "ASoC: error - multiple DAI %s registered with no name\n", + dev_name(dev)); return NULL; } @@ -3859,8 +3866,9 @@ static int snd_soc_register_dais(struct device *dev, list_for_each_entry(codec, &codec_list, list) { if (codec->dev == dev) { - dev_dbg(dev, "ASoC: Mapped DAI %s to " - "CODEC %s\n", dai->name, codec->name); + dev_dbg(dev, + "ASoC: Mapped DAI %s to CODEC %s\n", + dai->name, codec->name); dai->codec = codec; break; } @@ -4296,8 +4304,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, num_routes = of_property_count_strings(np, propname); if (num_routes < 0 || num_routes & 1) { - dev_err(card->dev, "ASoC: Property '%s' does not exist or its" - " length is not even\n", propname); + dev_err(card->dev, + "ASoC: Property '%s' does not exist or its length is not even\n", + propname); return -EINVAL; } num_routes /= 2; From 8011412999484a82a23dc3c9a5c9d5a1677ca05d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 25 Feb 2013 15:14:19 +0000 Subject: [PATCH 2/7] ASoC: dapm: Provide early event callbacks for power up and down Some devices may benefit from being able to start some parts of the widget power up/down sequence earlier on in the sequence than the point at which the final power state is committed. Support these by providing events which are called before any power state changes are done. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dapm.h | 2 ++ sound/soc/soc-dapm.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index d4609029f014..f4f85dd1cd97 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -311,6 +311,8 @@ struct device; #define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ #define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ #define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ +#define SND_SOC_DAPM_WILL_PMU 0x40 /* called at start of sequence */ +#define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */ #define SND_SOC_DAPM_PRE_POST_PMD \ (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index a80c883bb8be..e4e5420de725 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1277,6 +1277,14 @@ static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm, ev_name = "POST_PMD"; power = 0; break; + case SND_SOC_DAPM_WILL_PMU: + ev_name = "WILL_PMU"; + power = 1; + break; + case SND_SOC_DAPM_WILL_PMD: + ev_name = "WILL_PMD"; + power = 0; + break; default: BUG(); return; @@ -1737,6 +1745,14 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) &async_domain); async_synchronize_full_domain(&async_domain); + list_for_each_entry(w, &down_list, list) { + dapm_seq_check_event(dapm, w, SND_SOC_DAPM_WILL_PMD); + } + + list_for_each_entry(w, &up_list, list) { + dapm_seq_check_event(dapm, w, SND_SOC_DAPM_WILL_PMU); + } + /* Power down widgets first; try to avoid amplifying pops. */ dapm_seq_run(dapm, &down_list, event, false); From 90996f43b3fa36075e501a52a3e2286896d74e79 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 14 May 2013 11:05:30 +0200 Subject: [PATCH 3/7] ASoC: core: Move snd_soc_set_runtime_hwparams() to soc-pcm.c snd_soc_set_runtime_hwparams() is the only PCM related function that lives in soc-core.c. All other PCM related functions live in soc-pcm.c, so move snd_soc_set_runtime_hwparams() over as well for a bit more consistency. Signed-off-by: Lars-Peter Clausen Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 23 ----------------------- sound/soc/soc-pcm.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 308895a438d6..9d95ef531308 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2219,29 +2219,6 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, } EXPORT_SYMBOL_GPL(snd_soc_test_bits); -/** - * snd_soc_set_runtime_hwparams - set the runtime hardware parameters - * @substream: the pcm substream - * @hw: the hardware parameters - * - * Sets the substream runtime hardware parameters. - */ -int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, - const struct snd_pcm_hardware *hw) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - runtime->hw.info = hw->info; - runtime->hw.formats = hw->formats; - runtime->hw.period_bytes_min = hw->period_bytes_min; - runtime->hw.period_bytes_max = hw->period_bytes_max; - runtime->hw.periods_min = hw->periods_min; - runtime->hw.periods_max = hw->periods_max; - runtime->hw.buffer_bytes_max = hw->buffer_bytes_max; - runtime->hw.fifo_size = hw->fifo_size; - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); - /** * snd_soc_cnew - create new control * @_template: control template diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 73bb8eefa491..058b40378451 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -33,6 +33,29 @@ #define DPCM_MAX_BE_USERS 8 +/** + * snd_soc_set_runtime_hwparams - set the runtime hardware parameters + * @substream: the pcm substream + * @hw: the hardware parameters + * + * Sets the substream runtime hardware parameters. + */ +int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, + const struct snd_pcm_hardware *hw) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + runtime->hw.info = hw->info; + runtime->hw.formats = hw->formats; + runtime->hw.period_bytes_min = hw->period_bytes_min; + runtime->hw.period_bytes_max = hw->period_bytes_max; + runtime->hw.periods_min = hw->periods_min; + runtime->hw.periods_max = hw->periods_max; + runtime->hw.buffer_bytes_max = hw->buffer_bytes_max; + runtime->hw.fifo_size = hw->fifo_size; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_set_runtime_hwparams); + /* DPCM stream event, send event to FE and all active BEs. */ static int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, int event) From bd477c31ca3ae85645fb2852bfa3954a623f9237 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 14 May 2013 11:05:31 +0200 Subject: [PATCH 4/7] ASoC: core: Add helper function to initialize the runtime pcm We use the same code to initialize the runtime pcm based on the snd_soc_pcm_stream struct on both the playback and capture path. Factor this code into a helper function to make things a bit more tidy. Signed-off-by: Lars-Peter Clausen Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 68 ++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 058b40378451..2f6f545f4ee8 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -147,6 +147,26 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, } } +static void soc_pcm_init_runtime_hw(struct snd_pcm_hardware *hw, + struct snd_soc_pcm_stream *codec_stream, + struct snd_soc_pcm_stream *cpu_stream) +{ + hw->rate_min = max(codec_stream->rate_min, cpu_stream->rate_min); + hw->rate_max = max(codec_stream->rate_max, cpu_stream->rate_max); + hw->channels_min = max(codec_stream->channels_min, + cpu_stream->channels_min); + hw->channels_max = min(codec_stream->channels_max, + cpu_stream->channels_max); + hw->formats = codec_stream->formats & cpu_stream->formats; + hw->rates = codec_stream->rates & cpu_stream->rates; + if (codec_stream->rates + & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) + hw->rates |= cpu_stream->rates; + if (cpu_stream->rates + & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) + hw->rates |= codec_stream->rates; +} + /* * Called by ALSA when a PCM substream is opened, the runtime->hw record is * then initialized and any private data can be allocated. This also calls @@ -212,51 +232,11 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) /* Check that the codec and cpu DAIs are compatible */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - runtime->hw.rate_min = - max(codec_dai_drv->playback.rate_min, - cpu_dai_drv->playback.rate_min); - runtime->hw.rate_max = - min(codec_dai_drv->playback.rate_max, - cpu_dai_drv->playback.rate_max); - runtime->hw.channels_min = - max(codec_dai_drv->playback.channels_min, - cpu_dai_drv->playback.channels_min); - runtime->hw.channels_max = - min(codec_dai_drv->playback.channels_max, - cpu_dai_drv->playback.channels_max); - runtime->hw.formats = - codec_dai_drv->playback.formats & cpu_dai_drv->playback.formats; - runtime->hw.rates = - codec_dai_drv->playback.rates & cpu_dai_drv->playback.rates; - if (codec_dai_drv->playback.rates - & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) - runtime->hw.rates |= cpu_dai_drv->playback.rates; - if (cpu_dai_drv->playback.rates - & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) - runtime->hw.rates |= codec_dai_drv->playback.rates; + soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->playback, + &cpu_dai_drv->playback); } else { - runtime->hw.rate_min = - max(codec_dai_drv->capture.rate_min, - cpu_dai_drv->capture.rate_min); - runtime->hw.rate_max = - min(codec_dai_drv->capture.rate_max, - cpu_dai_drv->capture.rate_max); - runtime->hw.channels_min = - max(codec_dai_drv->capture.channels_min, - cpu_dai_drv->capture.channels_min); - runtime->hw.channels_max = - min(codec_dai_drv->capture.channels_max, - cpu_dai_drv->capture.channels_max); - runtime->hw.formats = - codec_dai_drv->capture.formats & cpu_dai_drv->capture.formats; - runtime->hw.rates = - codec_dai_drv->capture.rates & cpu_dai_drv->capture.rates; - if (codec_dai_drv->capture.rates - & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) - runtime->hw.rates |= cpu_dai_drv->capture.rates; - if (cpu_dai_drv->capture.rates - & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) - runtime->hw.rates |= codec_dai_drv->capture.rates; + soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->capture, + &cpu_dai_drv->capture); } ret = -EINVAL; From 2b581074357c42f63ae827ee28c9f244b91a38ac Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 14 May 2013 11:05:32 +0200 Subject: [PATCH 5/7] ASoC: core: Use kasprintf instead of opencoding it kasprintf calculates the size of the result string, allocates a buffer large enough to hold the string and then performs the format string operation. There are a couple of places in ASoC where these three steps are done by hand and where kasprintf can be used instead. Signed-off-by: Lars-Peter Clausen Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 6 +----- sound/soc/soc-dapm.c | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9d95ef531308..4489c5b7b53a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2237,7 +2237,6 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, struct snd_kcontrol_new template; struct snd_kcontrol *kcontrol; char *name = NULL; - int name_len; memcpy(&template, _template, sizeof(template)); template.index = 0; @@ -2246,13 +2245,10 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, long_name = template.name; if (prefix) { - name_len = strlen(long_name) + strlen(prefix) + 2; - name = kmalloc(name_len, GFP_KERNEL); + name = kasprintf(GFP_KERNEL, "%s %s", prefix, long_name); if (!name) return NULL; - snprintf(name, name_len, "%s %s", prefix, long_name); - template.name = name; } else { template.name = long_name; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e4e5420de725..071579be7cb9 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -521,7 +521,6 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, int wlistentries; size_t wlistsize; bool wname_in_long_name, kcname_in_long_name; - size_t name_len; char *long_name; const char *name; int ret; @@ -586,25 +585,19 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, } if (wname_in_long_name && kcname_in_long_name) { - name_len = strlen(w->name) - prefix_len + 1 + - strlen(w->kcontrol_news[kci].name) + 1; - - long_name = kmalloc(name_len, GFP_KERNEL); - if (long_name == NULL) { - kfree(wlist); - return -ENOMEM; - } - /* * The control will get a prefix from the control * creation process but we're also using the same * prefix for widgets so cut the prefix off the * front of the widget name. */ - snprintf(long_name, name_len, "%s %s", + long_name = kasprintf(GFP_KERNEL, "%s %s", w->name + prefix_len, w->kcontrol_news[kci].name); - long_name[name_len - 1] = '\0'; + if (long_name == NULL) { + kfree(wlist); + return -ENOMEM; + } name = long_name; } else if (wname_in_long_name) { @@ -3077,7 +3070,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget) { struct snd_soc_dapm_widget *w; - size_t name_len; int ret; if ((w = dapm_cnew_widget(widget)) == NULL) @@ -3118,19 +3110,16 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, break; } - name_len = strlen(widget->name) + 1; if (dapm->codec && dapm->codec->name_prefix) - name_len += 1 + strlen(dapm->codec->name_prefix); - w->name = kmalloc(name_len, GFP_KERNEL); + w->name = kasprintf(GFP_KERNEL, "%s %s", + dapm->codec->name_prefix, widget->name); + else + w->name = kasprintf(GFP_KERNEL, "%s", widget->name); + if (w->name == NULL) { kfree(w); return NULL; } - if (dapm->codec && dapm->codec->name_prefix) - snprintf((char *)w->name, name_len, "%s %s", - dapm->codec->name_prefix, widget->name); - else - snprintf((char *)w->name, name_len, "%s", widget->name); switch (w->id) { case snd_soc_dapm_switch: From 7d0cd22382f80243e7fce16f6bfc0720d5688370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 17 May 2013 11:26:15 +0200 Subject: [PATCH 6/7] ASoC: simplify registration of snd-soc-dummy device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 4b3be6c3c91e..29b211e9c060 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -159,15 +159,10 @@ int __init snd_soc_util_init(void) { int ret; - soc_dummy_dev = platform_device_alloc("snd-soc-dummy", -1); - if (!soc_dummy_dev) - return -ENOMEM; - - ret = platform_device_add(soc_dummy_dev); - if (ret != 0) { - platform_device_put(soc_dummy_dev); - return ret; - } + soc_dummy_dev = + platform_device_register_simple("snd-soc-dummy", -1, NULL, 0); + if (IS_ERR(soc_dummy_dev)) + return PTR_ERR(soc_dummy_dev); ret = platform_driver_register(&soc_dummy_driver); if (ret != 0) From cf1f7c6e8756646db7a0d883013cedd90eb90dd4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 23 May 2013 00:12:53 +0200 Subject: [PATCH 7/7] ASoC: Fix early event callback list iteration The power_list field is used when adding a widget to a power sequence list. Use the same field when iterating the list using list_for_each_entry, otherwise we'll see undefined behavior. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 071579be7cb9..35073462d948 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1738,11 +1738,11 @@ static int dapm_power_widgets(struct snd_soc_dapm_context *dapm, int event) &async_domain); async_synchronize_full_domain(&async_domain); - list_for_each_entry(w, &down_list, list) { + list_for_each_entry(w, &down_list, power_list) { dapm_seq_check_event(dapm, w, SND_SOC_DAPM_WILL_PMD); } - list_for_each_entry(w, &up_list, list) { + list_for_each_entry(w, &up_list, power_list) { dapm_seq_check_event(dapm, w, SND_SOC_DAPM_WILL_PMU); }