OSDN Git Service

ASoC: soc-dai: add snd_soc_pcm_dai_probe()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 23 Apr 2020 23:15:15 +0000 (08:15 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 29 Apr 2020 12:27:40 +0000 (13:27 +0100)
We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_probe() to
snd_soc_pcm_dai_probe(). This patch do it.

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/87sggtssjg.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dai.h
sound/soc/soc-core.c
sound/soc/soc-dai.c

index a0c7ac1..bdb79df 100644 (file)
@@ -158,12 +158,12 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
                                    struct snd_pcm_substream *substream);
 void snd_soc_dai_suspend(struct snd_soc_dai *dai);
 void snd_soc_dai_resume(struct snd_soc_dai *dai);
-int snd_soc_dai_probe(struct snd_soc_dai *dai);
 int snd_soc_dai_remove(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
                             struct snd_soc_pcm_runtime *rtd, int num);
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
+int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
index 76167fa..8cafca4 100644 (file)
@@ -1273,26 +1273,6 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order)
        dai->probed = 0;
 }
 
-static int soc_probe_dai(struct snd_soc_dai *dai, int order)
-{
-       int ret;
-
-       if (dai->probed ||
-           dai->driver->probe_order != order)
-               return 0;
-
-       ret = snd_soc_dai_probe(dai);
-       if (ret < 0) {
-               dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n",
-                       dai->name, ret);
-               return ret;
-       }
-
-       dai->probed = 1;
-
-       return 0;
-}
-
 static void soc_remove_link_dais(struct snd_soc_card *card)
 {
        int i;
@@ -1311,9 +1291,8 @@ static void soc_remove_link_dais(struct snd_soc_card *card)
 
 static int soc_probe_link_dais(struct snd_soc_card *card)
 {
-       struct snd_soc_dai *dai;
        struct snd_soc_pcm_runtime *rtd;
-       int i, order, ret;
+       int order, ret;
 
        for_each_comp_order(order) {
                for_each_card_rtds(card, rtd) {
@@ -1322,12 +1301,10 @@ static int soc_probe_link_dais(struct snd_soc_card *card)
                                "ASoC: probe %s dai link %d late %d\n",
                                card->name, rtd->num, order);
 
-                       /* probe the CPU DAI */
-                       for_each_rtd_dais(rtd, i, dai) {
-                               ret = soc_probe_dai(dai, order);
-                               if (ret)
-                                       return ret;
-                       }
+                       /* probe all rtd connected DAIs in good order */
+                       ret = snd_soc_pcm_dai_probe(rtd, order);
+                       if (ret)
+                               return ret;
                }
        }
 
index 226c51b..48f5eb5 100644 (file)
@@ -366,16 +366,6 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
        return delay;
 }
 
-int snd_soc_dai_probe(struct snd_soc_dai *dai)
-{
-       int ret = 0;
-
-       if (dai->driver->probe)
-               ret = dai->driver->probe(dai);
-
-       return soc_dai_ret(dai, ret);
-}
-
 int snd_soc_dai_remove(struct snd_soc_dai *dai)
 {
        int ret = 0;
@@ -408,6 +398,28 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
        return stream->channels_min;
 }
 
+int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
+{
+       struct snd_soc_dai *dai;
+       int i;
+
+       for_each_rtd_dais(rtd, i, dai) {
+               if (dai->driver->probe_order != order)
+                       continue;
+
+               if (dai->driver->probe) {
+                       int ret = dai->driver->probe(dai);
+
+                       if (ret < 0)
+                               return soc_dai_ret(dai, ret);
+               }
+
+               dai->probed = 1;
+       }
+
+       return 0;
+}
+
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 {
        struct snd_soc_dai *dai;