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

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87r26ihn3u.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dai.h
sound/soc/soc-dai.c
sound/soc/soc-pcm.c

index 72b8e76f1cc45dabe753fa0fe3999507290c1a1d..6a5566d459adb24df0ffb0fcbde5f62fe7ab5372 100644 (file)
@@ -158,6 +158,8 @@ int snd_soc_dai_prepare(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream);
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
                        struct snd_pcm_substream *substream, int cmd);
+int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
+                       struct snd_pcm_substream *substream, int cmd);
 
 struct snd_soc_dai_ops {
        /*
index 18c447e169f694baf24a1909af690c53c0a46813..6f466cfcbeefe751f25fe57752a2ec96047b645a 100644 (file)
@@ -330,3 +330,15 @@ int snd_soc_dai_trigger(struct snd_soc_dai *dai,
 
        return ret;
 }
+
+int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
+                               struct snd_pcm_substream *substream,
+                               int cmd)
+{
+       int ret = 0;
+
+       if (dai->driver->ops->bespoke_trigger)
+               ret = dai->driver->ops->bespoke_trigger(substream, cmd, dai);
+
+       return ret;
+}
index a628b08f966e8311981be6cbaff7d746956d8024..a10627f1ceff5e5f7e263352e085f6c6ed573ba1 100644 (file)
@@ -1123,19 +1123,15 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
        int i, ret;
 
        for_each_rtd_codec_dai(rtd, i, codec_dai) {
-               if (codec_dai->driver->ops->bespoke_trigger) {
-                       ret = codec_dai->driver->ops->bespoke_trigger(substream,
-                                                               cmd, codec_dai);
-                       if (ret < 0)
-                               return ret;
-               }
-       }
-
-       if (cpu_dai->driver->ops->bespoke_trigger) {
-               ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai);
+               ret = snd_soc_dai_bespoke_trigger(codec_dai, substream, cmd);
                if (ret < 0)
                        return ret;
        }
+
+       snd_soc_dai_bespoke_trigger(cpu_dai, substream, cmd);
+       if (ret < 0)
+               return ret;
+
        return 0;
 }
 /*