Skip to content

Commit 038fcda

Browse files
Wang Qingdavem330
authored andcommitted
net: ethernet: cavium: use div64_u64() instead of do_div()
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 237d20c commit 038fcda

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
15391539
* compute the delta in terms of coprocessor clocks.
15401540
*/
15411541
delta = (u64)ppb << 32;
1542-
do_div(delta, oct->coproc_clock_rate);
1542+
div64_u64(delta, oct->coproc_clock_rate);
15431543

15441544
spin_lock_irqsave(&lio->ptp_lock, flags);
15451545
comp = lio_pci_readq(oct, CN6XXX_MIO_PTP_CLOCK_COMP);
@@ -1672,7 +1672,7 @@ static void liquidio_ptp_init(struct octeon_device *oct)
16721672
u64 clock_comp, cfg;
16731673

16741674
clock_comp = (u64)NSEC_PER_SEC << 32;
1675-
do_div(clock_comp, oct->coproc_clock_rate);
1675+
div64_u64(clock_comp, oct->coproc_clock_rate);
16761676
lio_pci_writeq(oct, clock_comp, CN6XXX_MIO_PTP_CLOCK_COMP);
16771677

16781678
/* Enable */

0 commit comments

Comments
 (0)