* [PATCH] imx/clk-pllv2: fix wrong do_div() usage
@ 2015-11-04 1:01 Nicolas Pitre
2015-11-23 5:57 ` Shawn Guo
2015-11-30 20:58 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Nicolas Pitre @ 2015-11-04 1:01 UTC (permalink / raw)
To: Shawn Guo, Sascha Hauer, Michael Turquette; +Cc: linux-clk
do_div() is meant to be used with an unsigned dividend.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
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;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] imx/clk-pllv2: fix wrong do_div() usage
2015-11-04 1:01 [PATCH] imx/clk-pllv2: fix wrong do_div() usage Nicolas Pitre
@ 2015-11-23 5:57 ` Shawn Guo
2015-11-30 20:58 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Shawn Guo @ 2015-11-23 5:57 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Sascha Hauer, Michael Turquette, Stephen Boyd, linux-clk
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;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] imx/clk-pllv2: fix wrong do_div() usage
2015-11-04 1:01 [PATCH] imx/clk-pllv2: fix wrong do_div() usage Nicolas Pitre
2015-11-23 5:57 ` Shawn Guo
@ 2015-11-30 20:58 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2015-11-30 20:58 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Shawn Guo, Sascha Hauer, Michael Turquette, linux-clk
On 11/03, Nicolas Pitre wrote:
> do_div() is meant to be used with an unsigned dividend.
>
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
>
Applied to clk-fixes
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-30 20:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 1:01 [PATCH] imx/clk-pllv2: fix wrong do_div() usage Nicolas Pitre
2015-11-23 5:57 ` Shawn Guo
2015-11-30 20:58 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox