From 01e0df6647e713469466c7bb6d7157c2e3046192 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 4 Sep 2014 19:44:04 +0200 Subject: ASoC: Set card->instantiated to false when removing the card Set card->instantiated to false when the card is removed to make sure that operations that expect the card to be fully instantiated do not run anymore during card removal. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1b422c5c36c8..ff9d2892f473 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3810,8 +3810,10 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card); */ int snd_soc_unregister_card(struct snd_soc_card *card) { - if (card->instantiated) + if (card->instantiated) { + card->instantiated = false; soc_cleanup_card_resources(card); + } dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); return 0; -- cgit v1.2.3 From 1c325f771a88579f227fe017e4ee77d852cf5435 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 4 Sep 2014 19:44:05 +0200 Subject: ASoC: Shutdown DAPM contexts when removing a card Currently when a ASoC sound card is unregistered we leave the individual components in their current state, just call the remove() callback and leave it to the drivers to do the proper shutdown/cleanup. This patch introduces a call to snd_soc_dapm_shutdown() when removing the card. This will make sure that all DAPM widgets are properly powered down and all DAPM contexts are put at the SND_SOC_BIAS_OFF level. This will ensure that all components are properly powered down when the card is removed. Since a lot of drivers manually go to SND_SOC_BIAS_OFF in their remove callback this will also allow us to remove a bit of duplicated code. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ff9d2892f473..068785fa1a06 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3812,6 +3812,7 @@ int snd_soc_unregister_card(struct snd_soc_card *card) { if (card->instantiated) { card->instantiated = false; + snd_soc_dapm_shutdown(card); soc_cleanup_card_resources(card); } dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); -- cgit v1.2.3 From 86dbf2ac6fcb2d2932d4610f2dfe0954aa0633f7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 4 Sep 2014 19:44:06 +0200 Subject: ASoC: Add support for automatically going to BIAS_OFF on suspend There is a substantial amount of drivers that in go to SND_SOC_BIAS_OFF on suspend and go back to SND_SOC_BIAS_SUSPEND on resume (Often this is even the only thing done in the suspend and resume handlers). This patch introduces a new suspend_bias_off flag, which when set by a driver will let the ASoC core automatically put the device's DAPM context at the SND_SOC_BIAS_OFF level during suspend. Once the device is resumed the DAPM context will go back to SND_SOC_BIAS_STANDBY (if the context is idle, otherwise to SND_SOC_BIAS_ON). This will allow us to remove a fair bit of duplicated code from the drivers. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 068785fa1a06..2bdf9a4ac2b4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4402,6 +4402,7 @@ int snd_soc_register_codec(struct device *dev, codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; codec->dapm.codec = codec; codec->dapm.idle_bias_off = codec_drv->idle_bias_off; + codec->dapm.suspend_bias_off = codec_drv->suspend_bias_off; if (codec_drv->seq_notifier) codec->dapm.seq_notifier = codec_drv->seq_notifier; if (codec_drv->set_bias_level) -- cgit v1.2.3 From a80932979a72ef9d4e66a69520c7588cc6de5699 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 4 Sep 2014 19:44:07 +0200 Subject: ASoC: Always run default suspend/resume code We do a bit more than just running the callbacks during suspend and resume these days (e.g. call regcache_mark_dirty() during suspend). But this is only when suspend and resume callbacks are specified for the driver, otherwise nothing is done. This means that drivers which don't want to do anything special during suspend and resume, but still want the standard operations to run, need to provide empty suspend and resume callback functions (rather than no callbacks). This patch updates the suspend and resume code to always run standard sequence regardless of whether suspend and resume handlers are provided. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2bdf9a4ac2b4..c612900c80ff 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -637,7 +637,7 @@ int snd_soc_suspend(struct device *dev) list_for_each_entry(codec, &card->codec_dev_list, card_list) { /* If there are paths active then the CODEC will be held with * bias _ON and should not be suspended. */ - if (!codec->suspended && codec->driver->suspend) { + if (!codec->suspended) { switch (codec->dapm.bias_level) { case SND_SOC_BIAS_STANDBY: /* @@ -651,8 +651,10 @@ int snd_soc_suspend(struct device *dev) "ASoC: idle_bias_off CODEC on over suspend\n"); break; } + case SND_SOC_BIAS_OFF: - codec->driver->suspend(codec); + if (codec->driver->suspend) + codec->driver->suspend(codec); codec->suspended = 1; codec->cache_sync = 1; if (codec->component.regmap) @@ -726,11 +728,12 @@ static void soc_resume_deferred(struct work_struct *work) * left with bias OFF or STANDBY and suspended so we must now * resume. Otherwise the suspend was suppressed. */ - if (codec->driver->resume && codec->suspended) { + if (codec->suspended) { switch (codec->dapm.bias_level) { case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_OFF: - codec->driver->resume(codec); + if (codec->driver->resume) + codec->driver->resume(codec); codec->suspended = 0; break; default: -- cgit v1.2.3