lkml.org 
[lkml]   [2022]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging: pi433: Use div64_u64 instead of do_div
Date
This commit removes warning generated by cocci as follows:

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

Using div64_u64 instead of do_div can avoid potential truncation.

Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
drivers/staging/pi433/rf69.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 8c7fab6a46bb..683dd94489f9 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -252,11 +252,11 @@ int rf69_set_deviation(struct spi_device *spi, u32 deviation)

// calculat f step
f_step = F_OSC * factor;
- do_div(f_step, 524288); // 524288 = 2^19
+ div64_u64(f_step, 524288); // 524288 = 2^19

// 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);
@@ -291,7 +291,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)

// calculat f step
f_step = F_OSC * factor;
- do_div(f_step, 524288); // 524288 = 2^19
+ div64_u64(f_step, 524288); // 524288 = 2^19

// check input value
f_max = div_u64(f_step * 8388608, factor);
@@ -302,7 +302,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 frequency)

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

msb = (f_reg & 0xff0000) >> 16;
mid = (f_reg & 0xff00) >> 8;
--
2.34.1
\
 
 \ /
  Last update: 2022-10-19 12:13    [W:0.039 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site