From: Peter Rosin <peda@axentia.se>
To: Howard Mitchell <hm@hmbedded.co.uk>,
"broonie@kernel.org" <broonie@kernel.org>
Cc: "tiwai@suse.de" <tiwai@suse.de>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"perex@perex.cz" <perex@perex.cz>,
"corbet@lwn.net" <corbet@lwn.net>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] ASoC:pcm512x: Fix divide by zero issue.
Date: Sun, 22 Mar 2015 21:16:10 +0000 [thread overview]
Message-ID: <d68a8abc921f45619e077d52d444a7f7@EMAIL.axentia.se> (raw)
In-Reply-To: <1426886025-10731-1-git-send-email-hm@hmbedded.co.uk>
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@hmbedded.co.uk>
Acked-by: Peter Rosin <peda@axentia.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
prev parent reply other threads:[~2015-03-22 21:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-20 21:13 Howard Mitchell
2015-03-22 16:19 ` Mark Brown
2015-03-22 21:16 ` Peter Rosin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d68a8abc921f45619e077d52d444a7f7@EMAIL.axentia.se \
--to=peda@axentia.se \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=hm@hmbedded.co.uk \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®