[PATCH net-next] can: rockchip_canfd: Use div_s64() in rkcanfd_timestamp_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When building with clang for a 32-bit target, such as arm, a libcall is
generated when dividing the result of clocksource_cyc2ns(), which
returns a signed 64-bit integer:

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

Use div_s64() to avoid generating the libcall.

Fixes: 4e1a18bab124 ("can: rockchip_canfd: add hardware timestamping support")
Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
---
This does not happen with GCC, likely because it implements
optimizations for division by a constant that clang does not implement.
---
 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 81cccc5fd8384ee1fec919077db48632f0fe7cc2..4ca01d385ffffdeec964b7fd954d8ba3ba3a1381 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_s64(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: bfba7bc8b7c2c100b76edb3a646fdce256392129
change-id: 20240909-rockchip-canfd-clang-div-libcall-ba9f619434bf

Best regards,
-- 
Nathan Chancellor <nathan@xxxxxxxxxx>





[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux