linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Use div64_ul instead of do_div
@ 2021-11-17  1:12 cgel.zte
  2021-11-18  8:28 ` [PATCH v2] " cgel.zte
  0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-11-17  1:12 UTC (permalink / raw)
  To: avifishman70
  Cc: tmaimon77, tali.perry1, venture, yuenn, benjaminfair, mturquette,
	sboyd, openbmc, linux-clk, linux-kernel, Changcheng Deng,
	Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

do_div() does a 64-by-32 division. If the divisor is unsigned long, using
div64_ul can avoid truncation to 32-bit.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/clk/clk-npcm7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c
index e677bb5a784b..c75880af2b74 100644
--- a/drivers/clk/clk-npcm7xx.c
+++ b/drivers/clk/clk-npcm7xx.c
@@ -56,7 +56,7 @@ static unsigned long npcm7xx_clk_pll_recalc_rate(struct clk_hw *hw,
 	otdv2 = FIELD_GET(PLLCON_OTDV2, val);
 
 	ret = (u64)parent_rate * fbdv;
-	do_div(ret, indv * otdv1 * otdv2);
+	div64_ul(ret, indv * otdv1 * otdv2);
 
 	return ret;
 }
-- 
2.25.1


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

* [PATCH v2] clk: Use div64_ul instead of do_div
  2021-11-17  1:12 [PATCH] clk: Use div64_ul instead of do_div cgel.zte
@ 2021-11-18  8:28 ` cgel.zte
  2021-12-02 23:15   ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-11-18  8:28 UTC (permalink / raw)
  To: avifishman70
  Cc: benjaminfair, linux-clk, linux-kernel, mturquette, openbmc,
	sboyd, tali.perry1, tmaimon77, venture, yuenn, zealci, cgel.zte,
	deng.changcheng

From: Changcheng Deng <deng.changcheng@zte.com.cn>

do_div() does a 64-by-32 division. Here the divisor is an unsigned long
which on some platforms is 64 bit wide. So use div64_ul instead of do_div
to avoid a possible truncation.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/clk/clk-npcm7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-npcm7xx.c b/drivers/clk/clk-npcm7xx.c
index e677bb5a784b..c75880af2b74 100644
--- a/drivers/clk/clk-npcm7xx.c
+++ b/drivers/clk/clk-npcm7xx.c
@@ -56,7 +56,7 @@ static unsigned long npcm7xx_clk_pll_recalc_rate(struct clk_hw *hw,
 	otdv2 = FIELD_GET(PLLCON_OTDV2, val);
 
 	ret = (u64)parent_rate * fbdv;
-	do_div(ret, indv * otdv1 * otdv2);
+	ret = div64_ul(ret, indv * otdv1 * otdv2);
 
 	return ret;
 }
-- 
2.25.1


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

* Re: [PATCH v2] clk: Use div64_ul instead of do_div
  2021-11-18  8:28 ` [PATCH v2] " cgel.zte
@ 2021-12-02 23:15   ` Stephen Boyd
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2021-12-02 23:15 UTC (permalink / raw)
  To: avifishman70, cgel.zte
  Cc: benjaminfair, linux-clk, linux-kernel, mturquette, openbmc,
	tali.perry1, tmaimon77, venture, yuenn, zealci, cgel.zte,
	deng.changcheng

Please fix the subject. It should be "clk: npcm7xx: Use ..."

Quoting cgel.zte@gmail.com (2021-11-18 00:28:58)
> From: Changcheng Deng <deng.changcheng@zte.com.cn>
> 
> do_div() does a 64-by-32 division. Here the divisor is an unsigned long
> which on some platforms is 64 bit wide. So use div64_ul instead of do_div
> to avoid a possible truncation.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>

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

end of thread, other threads:[~2021-12-02 23:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17  1:12 [PATCH] clk: Use div64_ul instead of do_div cgel.zte
2021-11-18  8:28 ` [PATCH v2] " cgel.zte
2021-12-02 23:15   ` Stephen Boyd

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