Skip to content

Commit cd0983c

Browse files
arndbmarckleinebudde
authored andcommitted
can: rockchip_canfd: rkcanfd_timestamp_init(): rework delay calculation
Rework the delay calculation to only require a single 64-bit division. Signed-off-by: Arnd Bergmann <[email protected]> [mkl: port to on-top of existing 32-bit division fix] Link: https://patch.msgid.link/20240911-can-rockchip_canfd-fixes-v1-1-5ce385b5ab10@pengutronix.de Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 709cbd5 commit cd0983c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/can/rockchip/rockchip_canfd-timestamp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void rkcanfd_timestamp_init(struct rkcanfd_priv *priv)
7171

7272
max_cycles = div_u64(ULLONG_MAX, cc->mult);
7373
max_cycles = min(max_cycles, cc->mask);
74-
work_delay_ns = div_u64(clocksource_cyc2ns(max_cycles, cc->mult, cc->shift), 3);
75-
priv->work_delay_jiffies = nsecs_to_jiffies(work_delay_ns);
74+
work_delay_ns = clocksource_cyc2ns(max_cycles, cc->mult, cc->shift);
75+
priv->work_delay_jiffies = div_u64(work_delay_ns, 3u * NSEC_PER_SEC / HZ);
7676
INIT_DELAYED_WORK(&priv->timestamp, rkcanfd_timestamp_work);
7777

7878
netdev_dbg(priv->ndev, "clock=%lu.%02luMHz bitrate=%lu.%02luMBit/s div=%u rate=%lu.%02luMHz mult=%u shift=%u delay=%lus\n",

0 commit comments

Comments
 (0)