]> Git Repo - linux.git/commitdiff
ASoC: soc-pcm: add soc_rtd_trigger()
authorKuninori Morimoto <[email protected]>
Wed, 22 Jan 2020 00:44:56 +0000 (09:44 +0900)
committerMark Brown <[email protected]>
Thu, 23 Jan 2020 12:20:02 +0000 (12:20 +0000)
Add soc_rtd_trigger() to make the code easier to read

Signed-off-by: Kuninori Morimoto <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ranjani Sridharan <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
sound/soc/soc-pcm.c

index 718749f12979ba09de5090a3f90998184c12c33b..e66ac9ce321b70548423ad685d37daad110abb02 100644 (file)
@@ -72,6 +72,16 @@ static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd,
                rtd->dai_link->ops->hw_free(substream);
 }
 
+static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
+                          struct snd_pcm_substream *substream,
+                          int cmd)
+{
+       if (rtd->dai_link->ops &&
+           rtd->dai_link->ops->trigger)
+               return rtd->dai_link->ops->trigger(substream, cmd);
+       return 0;
+}
+
 /**
  * snd_soc_runtime_activate() - Increment active count for PCM runtime components
  * @rtd: ASoC PCM runtime that is activated
@@ -1013,11 +1023,9 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
        struct snd_soc_dai *codec_dai;
        int i, ret;
 
-       if (rtd->dai_link->ops->trigger) {
-               ret = rtd->dai_link->ops->trigger(substream, cmd);
-               if (ret < 0)
-                       return ret;
-       }
+       ret = soc_rtd_trigger(rtd, substream, cmd);
+       if (ret < 0)
+               return ret;
 
        for_each_rtd_components(rtd, i, component) {
                ret = snd_soc_component_trigger(component, substream, cmd);
@@ -1062,11 +1070,9 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
                        return ret;
        }
 
-       if (rtd->dai_link->ops->trigger) {
-               ret = rtd->dai_link->ops->trigger(substream, cmd);
-               if (ret < 0)
-                       return ret;
-       }
+       ret = soc_rtd_trigger(rtd, substream, cmd);
+       if (ret < 0)
+               return ret;
 
        return 0;
 }
This page took 0.056389 seconds and 4 git commands to generate.