aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Mitchell <hm@hmbedded.co.uk>2015-03-20 17:13:45 -0400
committerMark Brown <broonie@kernel.org>2015-03-23 02:22:18 -0400
commitf073faa73626f41db7050a69edd5074c53ce6d6c (patch)
tree1e762fd2e3a730e66fae5025592c152fab82e51f
parent4d9b13c7cc803fbde59d7e998f7de2b9a2101c7e (diff)
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: Howard Mitchell <hm@hmbedded.co.uk> Signed-off-by: Mark Brown <broonie@sirena.org.uk> Cc: stable@vger.kernel.org
-rw-r--r--sound/soc/codecs/pcm512x.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 194f4c8c5611..0676ab8be03f 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -576,8 +576,8 @@ static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai,
576 576
577 /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */ 577 /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */
578 if (pllin_rate / den > 20000000 && num < 8) { 578 if (pllin_rate / den > 20000000 && num < 8) {
579 num *= 20000000 / (pllin_rate / den); 579 num *= DIV_ROUND_UP(pllin_rate / den, 20000000);
580 den *= 20000000 / (pllin_rate / den); 580 den *= DIV_ROUND_UP(pllin_rate / den, 20000000);
581 } 581 }
582 dev_dbg(dev, "num / den = %lu / %lu\n", num, den); 582 dev_dbg(dev, "num / den = %lu / %lu\n", num, den);
583 583