lkml.org 
[lkml]   [2022]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: dsa: ocelot: use div64_u64() instead of do_div()
Date
From: Wang Qing <wangqing@vivo.com>

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@vivo.com>
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index bf8d382..5c2482f
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -1178,7 +1178,7 @@ static void vsc9959_new_base_time(struct ocelot *ocelot, ktime_t base_time,
if (base_time < current_time) {
u64 nr_of_cycles = current_time - base_time;

- do_div(nr_of_cycles, cycle_time);
+ div64_u64(nr_of_cycles, cycle_time);
new_base_time += cycle_time * (nr_of_cycles + 1);
}

--
2.7.4
\
 
 \ /
  Last update: 2022-02-09 10:09    [W:0.038 / U:0.536 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site