Skip to content

Commit

Permalink
ASoC: soc-pcm: add soc_rtd_hw_params()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
morimoto authored and broonie committed Jan 23, 2020
1 parent 44c1a75 commit de9ad99
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions sound/soc/soc-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd,
return 0;
}

static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
if (rtd->dai_link->ops &&
rtd->dai_link->ops->hw_params)
return rtd->dai_link->ops->hw_params(substream, params);
return 0;
}

/**
* snd_soc_runtime_activate() - Increment active count for PCM runtime components
* @rtd: ASoC PCM runtime that is activated
Expand Down Expand Up @@ -826,13 +836,11 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
if (ret)
goto out;

if (rtd->dai_link->ops->hw_params) {
ret = rtd->dai_link->ops->hw_params(substream, params);
if (ret < 0) {
dev_err(rtd->card->dev, "ASoC: machine hw_params"
" failed: %d\n", ret);
goto out;
}
ret = soc_rtd_hw_params(rtd, substream, params);
if (ret < 0) {
dev_err(rtd->card->dev,
"ASoC: machine hw_params failed: %d\n", ret);
goto out;
}

for_each_rtd_codec_dai(rtd, i, codec_dai) {
Expand Down

0 comments on commit de9ad99

Please sign in to comment.