提交 f073faa7 编写于 作者: H Howard Mitchell 提交者: Mark Brown

ASoC: pcm512x: Fix divide by zero issue

If den=1 and pllin_rate>20MHz then den and num are adjusted to 0
causing a divide by zero error a few lines further on. Therefore
this patch correctly scales num and den such that
pllin_rate/den < 20MHz as required in the device data sheet.
Signed-off-by: NHoward Mitchell <hm@hmbedded.co.uk>
Signed-off-by: NMark Brown <broonie@sirena.org.uk>
Cc: stable@vger.kernel.org
上级 4d9b13c7
...@@ -576,8 +576,8 @@ static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai, ...@@ -576,8 +576,8 @@ static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai,
/* pllin_rate / P (or here, den) cannot be greater than 20 MHz */ /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */
if (pllin_rate / den > 20000000 && num < 8) { if (pllin_rate / den > 20000000 && num < 8) {
num *= 20000000 / (pllin_rate / den); num *= DIV_ROUND_UP(pllin_rate / den, 20000000);
den *= 20000000 / (pllin_rate / den); den *= DIV_ROUND_UP(pllin_rate / den, 20000000);
} }
dev_dbg(dev, "num / den = %lu / %lu\n", num, den); dev_dbg(dev, "num / den = %lu / %lu\n", num, den);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部