Skip to content

Commit 98334dc

Browse files
nathanchanceWim Van Sebroeck
authored andcommitted
watchdog: xilinx_wwdt: Use div_u64() in xilinx_wwdt_start()
After commit f1a43aa ("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: ClangBuiltLinux#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>
1 parent 8b3c366 commit 98334dc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/watchdog/xilinx_wwdt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/interrupt.h>
1010
#include <linux/io.h>
1111
#include <linux/ioport.h>
12+
#include <linux/math64.h>
1213
#include <linux/mod_devicetable.h>
1314
#include <linux/module.h>
1415
#include <linux/platform_device.h>
@@ -71,7 +72,7 @@ static int xilinx_wwdt_start(struct watchdog_device *wdd)
7172

7273
/* Calculate timeout count */
7374
time_out = xdev->freq * wdd->timeout;
74-
closed_timeout = (time_out * xdev->close_percent) / 100;
75+
closed_timeout = div_u64(time_out * xdev->close_percent, 100);
7576
open_timeout = time_out - closed_timeout;
7677
wdd->min_hw_heartbeat_ms = xdev->close_percent * 10 * wdd->timeout;
7778

0 commit comments

Comments
 (0)