mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 13:43:51 +00:00
ASoC: loongson: Simplify if statment in loongson_card_hw_params()
Deal with illegal conditions first and put the normal process code outside the if condition to improve code readability. Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn> Link: https://patch.msgid.link/98b71f9643970f11bc500c01599c7aeb77ff2a58.1725844530.git.zhoubinbin@loongson.cn Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
3d2528d6c0
commit
e28ee1b8a9
@ -24,27 +24,27 @@ static int loongson_card_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
||||
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
|
||||
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
|
||||
struct loongson_card_data *ls_card = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
|
||||
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
|
||||
int ret, mclk;
|
||||
|
||||
if (ls_card->mclk_fs) {
|
||||
mclk = ls_card->mclk_fs * params_rate(params);
|
||||
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
|
||||
SND_SOC_CLOCK_OUT);
|
||||
if (ret < 0) {
|
||||
dev_err(codec_dai->dev, "cpu_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
if (!ls_card->mclk_fs)
|
||||
return 0;
|
||||
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
|
||||
SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
dev_err(codec_dai->dev, "codec_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
mclk = ls_card->mclk_fs * params_rate(params);
|
||||
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT);
|
||||
if (ret < 0) {
|
||||
dev_err(codec_dai->dev, "cpu_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
dev_err(codec_dai->dev, "codec_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user