stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 01/17] clk: imx: Use div64_ul instead of do_div
@ 2022-01-17 17:05 Sasha Levin
  2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 02/17] powerpc/6xx: add missing of_node_put Sasha Levin
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Sasha Levin @ 2022-01-17 17:05 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Changcheng Deng, Zeal Robot, Abel Vesa, Sasha Levin, mturquette,
	sboyd, shawnguo, linux-clk, linux-imx, linux-arm-kernel

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

[ Upstream commit c1b6ad9a902539f9c037b6b3c35cb134c5724022 ]

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>
Reviewed-by: Abel Vesa <abel.vesa@nxp.com>
Link: https://lore.kernel.org/r/20211118080634.165275-1-deng.changcheng@zte.com.cn
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/clk/imx/clk-pllv3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 9af62ee8f347a..325a03e89cf8d 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -252,7 +252,7 @@ static long clk_pllv3_av_round_rate(struct clk_hw *hw, unsigned long rate,
 	div = rate / parent_rate;
 	temp64 = (u64) (rate - div * parent_rate);
 	temp64 *= mfd;
-	do_div(temp64, parent_rate);
+	temp64 = div64_ul(temp64, parent_rate);
 	mfn = temp64;
 
 	temp64 = (u64)parent_rate;
@@ -282,7 +282,7 @@ static int clk_pllv3_av_set_rate(struct clk_hw *hw, unsigned long rate,
 	div = rate / parent_rate;
 	temp64 = (u64) (rate - div * parent_rate);
 	temp64 *= mfd;
-	do_div(temp64, parent_rate);
+	temp64 = div64_ul(temp64, parent_rate);
 	mfn = temp64;
 
 	val = readl_relaxed(pll->base);
@@ -339,7 +339,7 @@ static struct clk_pllv3_vf610_mf clk_pllv3_vf610_rate_to_mf(
 		/* rate = parent_rate * (mfi + mfn/mfd) */
 		temp64 = rate - parent_rate * mf.mfi;
 		temp64 *= mf.mfd;
-		do_div(temp64, parent_rate);
+		temp64 = div64_ul(temp64, parent_rate);
 		mf.mfn = temp64;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2022-01-17 17:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-17 17:05 [PATCH AUTOSEL 4.19 01/17] clk: imx: Use div64_ul instead of do_div Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 02/17] powerpc/6xx: add missing of_node_put Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 03/17] powerpc/powernv: " Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 04/17] powerpc/cell: " Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 05/17] powerpc/btext: " Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 06/17] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 07/17] i2c: i801: Don't silently correct invalid transfer size Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 08/17] powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 09/17] i2c: mpc: Correct I2C reset procedure Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 10/17] w1: Misuse of get_user()/put_user() reported by sparse Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 11/17] ALSA: seq: Set upper limit of processed events Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 12/17] powerpc: handle kdump appropriately with crash_kexec_post_notifiers option Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 13/17] MIPS: OCTEON: add put_device() after of_find_device_by_node() Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 14/17] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 15/17] MIPS: Octeon: Fix build errors using clang Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 16/17] scsi: sr: Don't use GFP_DMA Sasha Levin
2022-01-17 17:05 ` [PATCH AUTOSEL 4.19 17/17] ASoC: mediatek: mt8173: fix device_node leak Sasha Levin

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