All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM: AVS: Use div64_ul instead of do_div
@ 2021-11-25  1:43 cgel.zte
  2021-12-01 15:12 ` (subset) " Bjorn Andersson
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2021-11-25  1:43 UTC (permalink / raw)
  To: nks
  Cc: agross, bjorn.andersson, linux-pm, linux-arm-msm, linux-kernel,
	Changcheng Deng, Zeal Robot

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/soc/qcom/cpr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/cpr.c b/drivers/soc/qcom/cpr.c
index 1d818a8ba208..e9b854ed1bdf 100644
--- a/drivers/soc/qcom/cpr.c
+++ b/drivers/soc/qcom/cpr.c
@@ -1010,7 +1010,7 @@ static int cpr_interpolate(const struct corner *corner, int step_volt,
 		return corner->uV;
 
 	temp = f_diff * (uV_high - uV_low);
-	do_div(temp, f_high - f_low);
+	temp = div64_ul(temp, f_high - f_low);
 
 	/*
 	 * max_volt_scale has units of uV/MHz while freq values
-- 
2.25.1


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

* Re: (subset) [PATCH] PM: AVS: Use div64_ul instead of do_div
  2021-11-25  1:43 [PATCH] PM: AVS: Use div64_ul instead of do_div cgel.zte
@ 2021-12-01 15:12 ` Bjorn Andersson
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Andersson @ 2021-12-01 15:12 UTC (permalink / raw)
  To: cgel.zte, nks
  Cc: linux-arm-msm, Changcheng Deng, agross, Zeal Robot, linux-kernel,
	linux-pm

On Thu, 25 Nov 2021 01:43:11 +0000, cgel.zte@gmail.com wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] PM: AVS: Use div64_ul instead of do_div
      commit: e07a98b28decb21f7bdbcb05bf2acc58ea03b1e4

Best regards,
-- 
Bjorn Andersson <bjorn.andersson@linaro.org>

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25  1:43 [PATCH] PM: AVS: Use div64_ul instead of do_div cgel.zte
2021-12-01 15:12 ` (subset) " Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.