ASoC: soc-card: add snd_soc_card_late_probe()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 28 May 2020 01:49:20 +0000 (10:49 +0900)
committerMark Brown <broonie@kernel.org>
Sat, 30 May 2020 01:11:37 +0000 (02:11 +0100)
Card related function should be implemented at soc-card now.
This patch adds it.

card has "card->probe" and "card->late_probe" callbacks,
and "late_probe" callback is called after "probe".
This means, we can set "card->probed" flag afer "late_probe"
for all cases.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87v9kgzv4w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-card.h
sound/soc/soc-card.c
sound/soc/soc-core.c

index 191285a..521dc05 100644 (file)
@@ -25,6 +25,7 @@ int snd_soc_card_resume_pre(struct snd_soc_card *card);
 int snd_soc_card_resume_post(struct snd_soc_card *card);
 
 int snd_soc_card_probe(struct snd_soc_card *card);
+int snd_soc_card_late_probe(struct snd_soc_card *card);
 
 /* device driver data */
 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
index ff3bf37..317771d 100644 (file)
@@ -142,3 +142,27 @@ int snd_soc_card_probe(struct snd_soc_card *card)
 
        return 0;
 }
+
+int snd_soc_card_late_probe(struct snd_soc_card *card)
+{
+       if (card->late_probe) {
+               int ret = card->late_probe(card);
+
+               if (ret < 0)
+                       return soc_card_ret(card, ret);
+       }
+
+       /*
+        * It has "card->probe" and "card->late_probe" callbacks,
+        * and "late_probe" callback is called after "probe".
+        * This means, we can set "card->probed" flag afer "late_probe"
+        * for all cases.
+        *
+        * see
+        *      snd_soc_bind_card()
+        *      snd_soc_card_probe()
+        */
+       card->probed = 1;
+
+       return 0;
+}
index 13a7d51..42e8c11 100644 (file)
@@ -1910,15 +1910,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
                }
        }
 
-       if (card->late_probe) {
-               ret = card->late_probe(card);
-               if (ret < 0) {
-                       dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n",
-                               card->name, ret);
-                       goto probe_end;
-               }
-       }
-       card->probed = 1;
+       ret = snd_soc_card_late_probe(card);
+       if (ret < 0)
+               goto probe_end;
 
        snd_soc_dapm_new_widgets(card);