Skip to content

Commit d9f31ae

Browse files
Yang Likuba-moo
authored andcommitted
ethernet: renesas: Use div64_ul instead of do_div
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. Eliminate the following coccicheck warning: ./drivers/net/ethernet/renesas/ravb_main.c:2492:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. Reported-by: Abaci Robot <[email protected]> Signed-off-by: Yang Li <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Sergey Shtylyov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8d22679 commit d9f31ae

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
#include <linux/spinlock.h>
3131
#include <linux/sys_soc.h>
3232
#include <linux/reset.h>
33-
34-
#include <asm/div64.h>
33+
#include <linux/math64.h>
3534

3635
#include "ravb.h"
3736

@@ -2488,8 +2487,7 @@ static int ravb_set_gti(struct net_device *ndev)
24882487
if (!rate)
24892488
return -EINVAL;
24902489

2491-
inc = 1000000000ULL << 20;
2492-
do_div(inc, rate);
2490+
inc = div64_ul(1000000000ULL << 20, rate);
24932491

24942492
if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) {
24952493
dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n",

0 commit comments

Comments
 (0)