Commit e28ee1b8 authored by Binbin Zhou's avatar Binbin Zhou Committed by Mark Brown

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: default avatarBinbin Zhou <zhoubinbin@loongson.cn>
Link: https://patch.msgid.link/98b71f9643970f11bc500c01599c7aeb77ff2a58.1725844530.git.zhoubinbin@loongson.cnSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3d2528d6
...@@ -24,27 +24,27 @@ static int loongson_card_hw_params(struct snd_pcm_substream *substream, ...@@ -24,27 +24,27 @@ static int loongson_card_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); 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 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; int ret, mclk;
if (ls_card->mclk_fs) { if (!ls_card->mclk_fs)
mclk = ls_card->mclk_fs * params_rate(params); return 0;
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, mclk = ls_card->mclk_fs * params_rate(params);
SND_SOC_CLOCK_IN); ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT);
if (ret < 0) { if (ret < 0) {
dev_err(codec_dai->dev, "codec_dai clock not set\n"); dev_err(codec_dai->dev, "cpu_dai clock not set\n");
return ret; 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment