linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] clk: socfpga: Fix integer overflow in clock calculation
Date: Wed, 26 Feb 2014 12:24:15 -0800	[thread overview]
Message-ID: <20140226202415.4353.59197@quantum> (raw)
In-Reply-To: <1393428786.5888.1.camel@b13cycling>

Quoting Dinh Nguyen (2014-02-26 07:33:06)
> On Wed, 2014-02-26 at 00:37 -0800, Mike Turquette wrote:
> > Quoting dinguyen at altera.com (2014-02-19 13:11:10)
> > > From: Dinh Nguyen <dinguyen@altera.com>
> > > 
> > > Use 64-bit integer for calculating clock rate. Also use do_div for the
> > > 64-bit division.
> > > 
> > > Signed-off-by: Graham Moore <grmoore@altera.com>
> > > Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
> > > Cc: Mike Turquette <mturquette@linaro.org>
> > > Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> > 
> > Changes to the clk driver look good to me.
> > 
> 
> Can you apply the first 2 patches to your tree? I'll send the 3rd dts
> patch through the arm-soc tree.

Done!

Regards,
Mike

> 
> Thanks alot...
> Dinh
> > Regards,
> > Mike
> > 
> > > ---
> > >  drivers/clk/socfpga/clk-pll.c |    8 +++++---
> > >  1 file changed, 5 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
> > > index 362004e..834b6e9 100644
> > > --- a/drivers/clk/socfpga/clk-pll.c
> > > +++ b/drivers/clk/socfpga/clk-pll.c
> > > @@ -44,7 +44,8 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
> > >                                          unsigned long parent_rate)
> > >  {
> > >         struct socfpga_pll *socfpgaclk = to_socfpga_clk(hwclk);
> > > -       unsigned long divf, divq, vco_freq, reg;
> > > +       unsigned long divf, divq, reg;
> > > +       unsigned long long vco_freq;
> > >         unsigned long bypass;
> > >  
> > >         reg = readl(socfpgaclk->hw.reg);
> > > @@ -54,8 +55,9 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk,
> > >  
> > >         divf = (reg & SOCFPGA_PLL_DIVF_MASK) >> SOCFPGA_PLL_DIVF_SHIFT;
> > >         divq = (reg & SOCFPGA_PLL_DIVQ_MASK) >> SOCFPGA_PLL_DIVQ_SHIFT;
> > > -       vco_freq = parent_rate * (divf + 1);
> > > -       return vco_freq / (1 + divq);
> > > +       vco_freq = (unsigned long long)parent_rate * (divf + 1);
> > > +       do_div(vco_freq, (1 + divq));
> > > +       return (unsigned long)vco_freq;
> > >  }
> > >  
> > >  static struct clk_ops clk_pll_ops = {
> > > -- 
> > > 1.7.9.5
> > > 
> 
> 

  reply	other threads:[~2014-02-26 20:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 21:11 [PATCH 1/3] clk: socfpga: Fix integer overflow in clock calculation dinguyen at altera.com
2014-02-19 21:11 ` [PATCH 2/3] clk: socfpga: Support multiple parents for the pll clocks dinguyen at altera.com
2014-02-19 21:11 ` [PATCH 3/3] dts: socfpga: Update clock entry to support multiple parents dinguyen at altera.com
2014-02-26  8:37 ` [PATCH 1/3] clk: socfpga: Fix integer overflow in clock calculation Mike Turquette
2014-02-26 15:33   ` Dinh Nguyen
2014-02-26 20:24     ` Mike Turquette [this message]
2014-02-27  9:58 ` Uwe Kleine-König

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=20140226202415.4353.59197@quantum \
    --to=mturquette@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).