patches.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: xilinx_wwdt: Use div_u64() in xilinx_wwdt_start()
@ 2023-08-15 19:06 Nathan Chancellor
  2023-08-15 20:07 ` Guenter Roeck
  2023-08-23 15:18 ` Rob Herring
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-08-15 19:06 UTC (permalink / raw)
  To: srinivas.neeli, wim
  Cc: shubhrajyoti.datta, michal.simek, linux, ndesaulniers, trix,
	linux-watchdog, linux-arm-kernel, patches, llvm,
	Nathan Chancellor

After commit f1a43aadb5a6 ("watchdog: Enable COMPILE_TEST for more
drivers"), it is possible to enable this driver on 32-bit architectures.
When building for those architectures with clang, there is an error due
to a 64-bit division in xilinx_wwdt_start():

  ERROR: modpost: "__aeabi_uldivmod" [drivers/watchdog/xilinx_wwdt.ko] undefined!

Use div_u64() to fix this, which takes a 64-bit dividend and 32-bit
divisor. GCC likely avoids the same error due to optimizations it
employs to transform division by a constant into other equivalent
operations, which may be different than what is implemented in clang.

Link: https://github.com/ClangBuiltLinux/linux/issues/1915
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/watchdog/xilinx_wwdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/xilinx_wwdt.c b/drivers/watchdog/xilinx_wwdt.c
index 1d998db41533..d271e2e8d6e2 100644
--- a/drivers/watchdog/xilinx_wwdt.c
+++ b/drivers/watchdog/xilinx_wwdt.c
@@ -9,6 +9,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/math64.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -71,7 +72,7 @@ static int xilinx_wwdt_start(struct watchdog_device *wdd)
 
 	/* Calculate timeout count */
 	time_out = xdev->freq * wdd->timeout;
-	closed_timeout = (time_out * xdev->close_percent) / 100;
+	closed_timeout = div_u64(time_out * xdev->close_percent, 100);
 	open_timeout = time_out - closed_timeout;
 	wdd->min_hw_heartbeat_ms = xdev->close_percent * 10 * wdd->timeout;
 

---
base-commit: 8a504bd61ec7b3ddd72680e15775f2c7c0f9e894
change-id: 20230815-watchdog-xilinx-div_u64-85c27c650493

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

end of thread, other threads:[~2023-08-23 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-15 19:06 [PATCH] watchdog: xilinx_wwdt: Use div_u64() in xilinx_wwdt_start() Nathan Chancellor
2023-08-15 20:07 ` Guenter Roeck
2023-08-23 15:18 ` Rob Herring

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).