Skip to content

Commit ad2bf9f

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-pcm: add soc_rtd_trigger()
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]>
1 parent 49f020e commit ad2bf9f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

sound/soc/soc-pcm.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd,
7272
rtd->dai_link->ops->hw_free(substream);
7373
}
7474

75+
static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
76+
struct snd_pcm_substream *substream,
77+
int cmd)
78+
{
79+
if (rtd->dai_link->ops &&
80+
rtd->dai_link->ops->trigger)
81+
return rtd->dai_link->ops->trigger(substream, cmd);
82+
return 0;
83+
}
84+
7585
/**
7686
* snd_soc_runtime_activate() - Increment active count for PCM runtime components
7787
* @rtd: ASoC PCM runtime that is activated
@@ -1013,11 +1023,9 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
10131023
struct snd_soc_dai *codec_dai;
10141024
int i, ret;
10151025

1016-
if (rtd->dai_link->ops->trigger) {
1017-
ret = rtd->dai_link->ops->trigger(substream, cmd);
1018-
if (ret < 0)
1019-
return ret;
1020-
}
1026+
ret = soc_rtd_trigger(rtd, substream, cmd);
1027+
if (ret < 0)
1028+
return ret;
10211029

10221030
for_each_rtd_components(rtd, i, component) {
10231031
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)
10621070
return ret;
10631071
}
10641072

1065-
if (rtd->dai_link->ops->trigger) {
1066-
ret = rtd->dai_link->ops->trigger(substream, cmd);
1067-
if (ret < 0)
1068-
return ret;
1069-
}
1073+
ret = soc_rtd_trigger(rtd, substream, cmd);
1074+
if (ret < 0)
1075+
return ret;
10701076

10711077
return 0;
10721078
}

0 commit comments

Comments
 (0)