netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: rockchip_canfd: rkcanfd_timestamp_init(): fix 64 bit division on 32 bit platforms
@ 2024-09-09  6:21 Marc Kleine-Budde
  2024-09-09 14:23 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2024-09-09  6:21 UTC (permalink / raw)
  To: kernel, Vincent Mailhol, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Heiko Stuebner
  Cc: linux-can, netdev, linux-arm-kernel, linux-rockchip, linux-kernel,
	kernel test robot, Marc Kleine-Budde

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/
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/rockchip/rockchip_canfd-timestamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
index 81cccc5fd838..fb1a8f4e6217 100644
--- a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
+++ b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
@@ -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);
 

---
base-commit: c259acab839e57eab0318f32da4ae803a8d59397
change-id: 20240909-can-rockchip_canfd-fix-64-bit-division-5f579fddebc9

Best regards,
-- 
Marc Kleine-Budde <mkl@pengutronix.de>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-09 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09  6:21 [PATCH] can: rockchip_canfd: rkcanfd_timestamp_init(): fix 64 bit division on 32 bit platforms Marc Kleine-Budde
2024-09-09 14:23 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).