linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] clk: sunxi: Fix incorrect usage of round_down()
@ 2020-03-17 21:13 Rikard Falkeborn
  2020-03-24 15:37 ` Maxime Ripard
  0 siblings, 1 reply; 2+ messages in thread
From: Rikard Falkeborn @ 2020-03-17 21:13 UTC (permalink / raw)
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Rikard Falkeborn,
	Emilio López, Michael Turquette, Stephen Boyd,
	Maxime Ripard, Chen-Yu Tsai

round_down() can only round to powers of 2. If round_down() is asked
to round to something that is not a power of 2, incorrect results are
produced. The incorrect results can be both too large and too small.

Instead, use rounddown() which can round to any number.

Fixes: 6a721db180a2 ("clk: sunxi: Add A31 clocks support")
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
Resend to include lists, appologies for missing that.

Patch has only been compile tested, I don't have the hardware.

 drivers/clk/sunxi/clk-sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 27201fd26e44..e1aa1fbac48a 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -90,7 +90,7 @@ static void sun6i_a31_get_pll1_factors(struct factors_request *req)
 	 * Round down the frequency to the closest multiple of either
 	 * 6 or 16
 	 */
-	u32 round_freq_6 = round_down(freq_mhz, 6);
+	u32 round_freq_6 = rounddown(freq_mhz, 6);
 	u32 round_freq_16 = round_down(freq_mhz, 16);
 
 	if (round_freq_6 > round_freq_16)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND] clk: sunxi: Fix incorrect usage of round_down()
  2020-03-17 21:13 [PATCH RESEND] clk: sunxi: Fix incorrect usage of round_down() Rikard Falkeborn
@ 2020-03-24 15:37 ` Maxime Ripard
  0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2020-03-24 15:37 UTC (permalink / raw)
  To: Rikard Falkeborn
  Cc: linux-clk, linux-arm-kernel, linux-kernel, Emilio López,
	Michael Turquette, Stephen Boyd, Chen-Yu Tsai

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

On Tue, Mar 17, 2020 at 10:13:32PM +0100, Rikard Falkeborn wrote:
> round_down() can only round to powers of 2. If round_down() is asked
> to round to something that is not a power of 2, incorrect results are
> produced. The incorrect results can be both too large and too small.
>
> Instead, use rounddown() which can round to any number.
>
> Fixes: 6a721db180a2 ("clk: sunxi: Add A31 clocks support")
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Queued for 5.8, thanks!
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-24 15:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 21:13 [PATCH RESEND] clk: sunxi: Fix incorrect usage of round_down() Rikard Falkeborn
2020-03-24 15:37 ` Maxime Ripard

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).