ASoC: soc-dai: add snd_soc_dai_probe()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 22 Jul 2019 01:34:56 +0000 (10:34 +0900)
committerMark Brown <broonie@kernel.org>
Tue, 23 Jul 2019 17:14:23 +0000 (18:14 +0100)
Current ALSA SoC is directly using dai->driver->xxx,
thus, it has deep nested bracket, and it makes code unreadable.
This patch adds new snd_soc_dai_probe() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k1cahn26.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 ed78e34a814e94ad360ec7f8aa60b758126ebe88..da8d8b8890893bd714c8302b6546629344153d5e 100644 (file)
@@ -164,6 +164,7 @@ 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);
 
 struct snd_soc_dai_ops {
        /*
index 5c02f90cea691a69baa5facb8b167a0f187736e8..3e73468225f9898967e7ea1d21547f381120a3f1 100644 (file)
@@ -1434,18 +1434,17 @@ static int soc_probe_link_components(struct snd_soc_card *card,
 
 static int soc_probe_dai(struct snd_soc_dai *dai, int order)
 {
+       int ret;
+
        if (dai->probed ||
            dai->driver->probe_order != order)
                return 0;
 
-       if (dai->driver->probe) {
-               int ret = dai->driver->probe(dai);
-
-               if (ret < 0) {
-                       dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n",
-                               dai->name, ret);
-                       return ret;
-               }
+       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;
index ddb6f217c0ed1eb376f97e826bb88cb2a3326eed..55c1fac9961361980d8f54156e803bc9d179e7b1 100644 (file)
@@ -365,3 +365,10 @@ void snd_soc_dai_resume(struct snd_soc_dai *dai)
        if (dai->driver->resume)
                dai->driver->resume(dai);
 }
+
+int snd_soc_dai_probe(struct snd_soc_dai *dai)
+{
+       if (dai->driver->probe)
+               return dai->driver->probe(dai);
+       return 0;
+}