[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d68a8abc921f45619e077d52d444a7f7@EMAIL.axentia.se>
Date: Sun, 22 Mar 2015 21:16:10 +0000
From: Peter Rosin <peda@...ntia.se>
To: Howard Mitchell <hm@...edded.co.uk>,
"broonie@...nel.org" <broonie@...nel.org>
CC: "tiwai@...e.de" <tiwai@...e.de>,
"lgirdwood@...il.com" <lgirdwood@...il.com>,
"perex@...ex.cz" <perex@...ex.cz>,
"corbet@....net" <corbet@....net>,
"alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] ASoC:pcm512x: Fix divide by zero issue.
Howard Mitchell wrote;
> 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.
Yep, the old code is plain broken and never actually ran, we have been
using 16MHz pllin_rate, and I apparently never hit this code path.
> Signed-off-by: Howard Mitchell <hm@...edded.co.uk>
Acked-by: Peter Rosin <peda@...ntia.se>
Cheers,
Peter
> ---
> sound/soc/codecs/pcm512x.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
> index 5301c4a..8472099 100644
> --- a/sound/soc/codecs/pcm512x.c
> +++ b/sound/soc/codecs/pcm512x.c
> @@ -713,8 +713,8 @@ static int pcm512x_find_pll_coeff(struct snd_soc_dai
> *dai,
>
> /* pllin_rate / P (or here, den) cannot be greater than 20 MHz */
> if (pllin_rate / den > 20000000 && num < 8) {
> - num *= 20000000 / (pllin_rate / den);
> - den *= 20000000 / (pllin_rate / den);
> + num *= DIV_ROUND_UP(pllin_rate / den, 20000000);
> + den *= DIV_ROUND_UP(pllin_rate / den, 20000000);
> }
> dev_dbg(dev, "num / den = %lu / %lu\n", num, den);
>
> --
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists