[PATCH] staging: pi433: use div64_u64() instead of do_div()

From: Qing Wang
Date: Wed Feb 09 2022 - 03:41:25 EST


From: Wang Qing <wangqing@xxxxxxxx>

do_div() does a 64-by-32 division.
When the divisor is u64, do_div() truncates it to 32 bits, this means it
can test non-zero and be truncated to zero for division.

fix do_div.cocci warning:
do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Signed-off-by: Wang Qing <wangqing@xxxxxxxx>
---
drivers/staging/pi433/rf69.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 2ab3bf4..cef542d
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -294,7 +294,7 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation)

// calculate register settings
f_reg = deviation * factor;
- do_div(f_reg, f_step);
+ div64_u64(f_reg, f_step);

msb = (f_reg & 0xff00) >> 8;
lsb = (f_reg & 0xff);
--
2.7.4