Skip to content

Commit 44c1a75

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-pcm: add soc_rtd_prepare()
Add soc_rtd_prepare() 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 0be429f commit 44c1a75

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

sound/soc/soc-pcm.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd,
4545
rtd->dai_link->ops->shutdown(substream);
4646
}
4747

48+
static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd,
49+
struct snd_pcm_substream *substream)
50+
{
51+
if (rtd->dai_link->ops &&
52+
rtd->dai_link->ops->prepare)
53+
return rtd->dai_link->ops->prepare(substream);
54+
return 0;
55+
}
56+
4857
/**
4958
* snd_soc_runtime_activate() - Increment active count for PCM runtime components
5059
* @rtd: ASoC PCM runtime that is activated
@@ -716,13 +725,11 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
716725

717726
mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
718727

719-
if (rtd->dai_link->ops->prepare) {
720-
ret = rtd->dai_link->ops->prepare(substream);
721-
if (ret < 0) {
722-
dev_err(rtd->card->dev, "ASoC: machine prepare error:"
723-
" %d\n", ret);
724-
goto out;
725-
}
728+
ret = soc_rtd_prepare(rtd, substream);
729+
if (ret < 0) {
730+
dev_err(rtd->card->dev,
731+
"ASoC: machine prepare error: %d\n", ret);
732+
goto out;
726733
}
727734

728735
for_each_rtd_components(rtd, i, component) {

0 commit comments

Comments
 (0)