未验证 提交 24cdbb79 编写于 作者: R Richard Fitzgerald 提交者: Mark Brown

ASoC: cs42l42: Validate dai_set_sysclk() frequency

If the machine driver calls snd_set_sysclk() with an unsupported
SCLK frequency, return an error instead of letting hw_params() fail.
Signed-off-by: NRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210805161111.10410-6-rf@opensource.cirrus.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 b962bae8
...@@ -891,10 +891,23 @@ static int cs42l42_set_sysclk(struct snd_soc_dai *dai, ...@@ -891,10 +891,23 @@ static int cs42l42_set_sysclk(struct snd_soc_dai *dai,
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
int i;
cs42l42->sclk = freq; if (freq == 0) {
cs42l42->sclk = 0;
return 0;
}
return 0; for (i = 0; i < ARRAY_SIZE(pll_ratio_table); i++) {
if (pll_ratio_table[i].sclk == freq) {
cs42l42->sclk = freq;
return 0;
}
}
dev_err(component->dev, "SCLK %u not supported\n", freq);
return -EINVAL;
} }
static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream) static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册