From: Shawn Guo <shawnguo@kernel.org>
To: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Sascha Hauer <kernel@pengutronix.de>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>,
linux-clk@vger.kernel.org
Subject: Re: [PATCH] imx/clk-pllv2: fix wrong do_div() usage
Date: Mon, 23 Nov 2015 13:57:12 +0800 [thread overview]
Message-ID: <20151123055712.GJ13744@tiger> (raw)
In-Reply-To: <alpine.LFD.2.20.1511031958530.630@knanqh.ubzr>
On Tue, Nov 03, 2015 at 08:01:40PM -0500, Nicolas Pitre wrote:
> do_div() is meant to be used with an unsigned dividend.
>
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Mike, Stephen,
Can you please apply it for v4.4-rc? Or I will queue it for v4.5-rc1.
Shawn
>
> diff --git a/drivers/clk/imx/clk-pllv2.c b/drivers/clk/imx/clk-pllv2.c
> index 20889d59b4..5fa6d1deac 100644
> --- a/drivers/clk/imx/clk-pllv2.c
> +++ b/drivers/clk/imx/clk-pllv2.c
> @@ -79,7 +79,7 @@ static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate,
> {
> long mfi, mfn, mfd, pdf, ref_clk, mfn_abs;
> unsigned long dbl;
> - s64 temp;
> + u64 temp;
>
> dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
>
> @@ -102,8 +102,9 @@ static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate,
> temp = (u64) ref_clk * mfn_abs;
> do_div(temp, mfd + 1);
> if (mfn < 0)
> - temp = -temp;
> - temp = (ref_clk * mfi) + temp;
> + temp = (ref_clk * mfi) - temp;
> + else
> + temp = (ref_clk * mfi) + temp;
>
> return temp;
> }
> @@ -130,7 +131,7 @@ static int __clk_pllv2_set_rate(unsigned long rate, unsigned long parent_rate,
> {
> u32 reg;
> long mfi, pdf, mfn, mfd = 999999;
> - s64 temp64;
> + u64 temp64;
> unsigned long quad_parent_rate;
>
> quad_parent_rate = 4 * parent_rate;
>
next prev parent reply other threads:[~2015-11-23 5:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 1:01 [PATCH] imx/clk-pllv2: fix wrong do_div() usage Nicolas Pitre
2015-11-23 5:57 ` Shawn Guo [this message]
2015-11-30 20:58 ` Stephen Boyd
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=20151123055712.GJ13744@tiger \
--to=shawnguo@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nicolas.pitre@linaro.org \
--cc=sboyd@codeaurora.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