]> git.dujemihanovic.xyz Git - linux.git/commitdiff
can: rockchip_canfd: rkcanfd_timestamp_init(): fix 64 bit division on 32 bit platforms
authorMarc Kleine-Budde <mkl@pengutronix.de>
Sun, 8 Sep 2024 15:00:00 +0000 (17:00 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 9 Sep 2024 06:31:02 +0000 (08:31 +0200)
On some 32-bit platforms (at least on parisc), the compiler generates
a call to __divdi3() from the u32 by 3 division in
rkcanfd_timestamp_init(), which results in the following linker
error:

| ERROR: modpost: "__divdi3" [drivers/net/can/rockchip/rockchip_canfd.ko] undefined!

As this code doesn't run in the hot path, a 64 bit by 32 bit division
is OK, even on 32 bit platforms. Use an explicit call to div_u64() to
fix linking.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202409072304.lCQWyNLU-lkp@intel.com/
Link: https://patch.msgid.link/20240909-can-rockchip_canfd-fix-64-bit-division-v1-1-2748d9422b00@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/rockchip/rockchip_canfd-timestamp.c

index 81cccc5fd8384ee1fec919077db48632f0fe7cc2..fb1a8f4e62172b06570b95e6f32c4c0f70fe1ea7 100644 (file)
@@ -71,7 +71,7 @@ void rkcanfd_timestamp_init(struct rkcanfd_priv *priv)
 
        max_cycles = div_u64(ULLONG_MAX, cc->mult);
        max_cycles = min(max_cycles, cc->mask);
-       work_delay_ns = clocksource_cyc2ns(max_cycles, cc->mult, cc->shift) / 3;
+       work_delay_ns = div_u64(clocksource_cyc2ns(max_cycles, cc->mult, cc->shift), 3);
        priv->work_delay_jiffies = nsecs_to_jiffies(work_delay_ns);
        INIT_DELAYED_WORK(&priv->timestamp, rkcanfd_timestamp_work);