From: Ray Jui <rjui@broadcom.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <linux-clk@vger.kernel.org>
Subject: Re: clk: iproc: add initial common clock support
Date: Fri, 26 Jun 2015 08:34:00 -0700 [thread overview]
Message-ID: <558D70E8.1010105@broadcom.com> (raw)
In-Reply-To: <20150626102359.GA32453@mwanda>
Hi Dan,
On 6/26/2015 3:23 AM, Dan Carpenter wrote:
> Hello Ray Jui,
>
> The patch 5fe225c105fd: "clk: iproc: add initial common clock
> support" from May 5, 2015, leads to the following static checker
> warning:
>
> drivers/clk/bcm/clk-iproc-pll.c:369 iproc_pll_recalc_rate()
> warn: should 'ndiv_int << ctrl->ndiv_int.shift' be a 64 bit type?
>
> drivers/clk/bcm/clk-iproc-pll.c
> 341 static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,
> 342 unsigned long parent_rate)
> 343 {
> 344 struct iproc_clk *clk = to_iproc_clk(hw);
> 345 struct iproc_pll *pll = clk->pll;
> 346 const struct iproc_pll_ctrl *ctrl = pll->ctrl;
> 347 u32 val;
> 348 u64 ndiv;
> 349 unsigned int ndiv_int, ndiv_frac, pdiv;
> 350
> 351 if (parent_rate == 0)
> 352 return 0;
> 353
> 354 /* PLL needs to be locked */
> 355 val = readl(pll->pll_base + ctrl->status.offset);
> 356 if ((val & (1 << ctrl->status.shift)) == 0) {
> 357 clk->rate = 0;
> 358 return 0;
> 359 }
> 360
> 361 /*
> 362 * PLL output frequency =
> 363 *
> 364 * ((ndiv_int + ndiv_frac / 2^20) * (parent clock rate / pdiv)
> 365 */
> 366 val = readl(pll->pll_base + ctrl->ndiv_int.offset);
> 367 ndiv_int = (val >> ctrl->ndiv_int.shift) &
> 368 bit_mask(ctrl->ndiv_int.width);
> 369 ndiv = ndiv_int << ctrl->ndiv_int.shift;
>
> ndiv is declared u64 but only the lower 32 bits are used because of
> shift wrapping.
>
> 370
> 371 if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) {
> 372 val = readl(pll->pll_base + ctrl->ndiv_frac.offset);
> 373 ndiv_frac = (val >> ctrl->ndiv_frac.shift) &
> 374 bit_mask(ctrl->ndiv_frac.width);
> 375
> 376 if (ndiv_frac != 0)
> 377 ndiv = (ndiv_int << ctrl->ndiv_int.shift) | ndiv_frac;
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Here as well.
>
> 378 }
>
> regards,
> dan carpenter
>
Got it. I'll fix both.
Thanks,
Ray
next prev parent reply other threads:[~2015-06-26 15:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 10:23 clk: iproc: add initial common clock support Dan Carpenter
2015-06-26 15:34 ` Ray Jui [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-06-26 10:20 Dan Carpenter
2015-06-26 15:31 ` Ray Jui
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=558D70E8.1010105@broadcom.com \
--to=rjui@broadcom.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-clk@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.