diff mbox

[2/5,v4] ASoC: soc-core: deactivate pins in snd_soc_instantiate_card()

Message ID 871tlu5sjx.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto Feb. 13, 2015, 4:43 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_instantiate_card() is the final method of snd_soc_register_card().
Deactivate pins to sleep state is related to snd_soc_instantiate_card(),
not snd_soc_register_card()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v3 -> v4

 - no change

 sound/soc/soc-core.c |   33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

Comments

Mark Brown March 22, 2015, 6:31 p.m. UTC | #1
On Fri, Feb 13, 2015 at 04:43:27AM +0000, Kuninori Morimoto wrote:

> snd_soc_instantiate_card() is the final method of snd_soc_register_card().
> Deactivate pins to sleep state is related to snd_soc_instantiate_card(),
> not snd_soc_register_card()

I'm not quite sure I understand why this is being done.  There doesn't
seem to be any reason to defer initialization of resources owned by a
device until the card is finally instantiated, doing this as early as
possible means that we're in the state we want to be even if we're still
waiting for some other component of the card to appear and register
itself (which may never happen of course) so the hardware is in the
state we want for longer.  I may be missing something here though.
diff mbox

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a760f6e..7f123bf 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1652,6 +1652,23 @@  static int snd_soc_instantiate_card(struct snd_soc_card *card)
 	snd_soc_dapm_sync(&card->dapm);
 	mutex_unlock(&card->mutex);
 
+	/* deactivate pins to sleep state */
+	for (i = 0; i < card->num_rtd; i++) {
+		struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
+		struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+		int j;
+
+		for (j = 0; j < rtd->num_codecs; j++) {
+			struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
+
+			if (!codec_dai->active)
+				pinctrl_pm_select_sleep_state(codec_dai->dev);
+		}
+
+		if (!cpu_dai->active)
+			pinctrl_pm_select_sleep_state(cpu_dai->dev);
+	}
+
 	return 0;
 
 probe_aux_dev_err:
@@ -2372,22 +2389,6 @@  int snd_soc_register_card(struct snd_soc_card *card)
 	if (ret != 0)
 		soc_cleanup_card_debugfs(card);
 
-	/* deactivate pins to sleep state */
-	for (i = 0; i < card->num_rtd; i++) {
-		struct snd_soc_pcm_runtime *rtd = &card->rtd[i];
-		struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-		int j;
-
-		for (j = 0; j < rtd->num_codecs; j++) {
-			struct snd_soc_dai *codec_dai = rtd->codec_dais[j];
-			if (!codec_dai->active)
-				pinctrl_pm_select_sleep_state(codec_dai->dev);
-		}
-
-		if (!cpu_dai->active)
-			pinctrl_pm_select_sleep_state(cpu_dai->dev);
-	}
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_register_card);