]> git.itanic.dy.fi Git - linux-stable/commitdiff
watchdog: xilinx_wwdt: Use div_u64() in xilinx_wwdt_start()
authorNathan Chancellor <nathan@kernel.org>
Tue, 15 Aug 2023 19:06:50 +0000 (12:06 -0700)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 19 Aug 2023 15:36:18 +0000 (17:36 +0200)
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>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230815-watchdog-xilinx-div_u64-v1-1-20b0b5a65c2e@kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/xilinx_wwdt.c

index 1d998db41533501f1a24c4603df480b327052758..d271e2e8d6e27141e4112edddcb58d72556509bb 100644 (file)
@@ -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;