Skip to content

Commit de9ad99

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

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

sound/soc/soc-pcm.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd,
5454
return 0;
5555
}
5656

57+
static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd,
58+
struct snd_pcm_substream *substream,
59+
struct snd_pcm_hw_params *params)
60+
{
61+
if (rtd->dai_link->ops &&
62+
rtd->dai_link->ops->hw_params)
63+
return rtd->dai_link->ops->hw_params(substream, params);
64+
return 0;
65+
}
66+
5767
/**
5868
* snd_soc_runtime_activate() - Increment active count for PCM runtime components
5969
* @rtd: ASoC PCM runtime that is activated
@@ -826,13 +836,11 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
826836
if (ret)
827837
goto out;
828838

829-
if (rtd->dai_link->ops->hw_params) {
830-
ret = rtd->dai_link->ops->hw_params(substream, params);
831-
if (ret < 0) {
832-
dev_err(rtd->card->dev, "ASoC: machine hw_params"
833-
" failed: %d\n", ret);
834-
goto out;
835-
}
839+
ret = soc_rtd_hw_params(rtd, substream, params);
840+
if (ret < 0) {
841+
dev_err(rtd->card->dev,
842+
"ASoC: machine hw_params failed: %d\n", ret);
843+
goto out;
836844
}
837845

838846
for_each_rtd_codec_dai(rtd, i, codec_dai) {

0 commit comments

Comments
 (0)