summaryrefslogtreecommitdiff
path: root/drivers/watchdog/rti_wdt.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2022-02-21 19:22:38 +0300
committerWim Van Sebroeck <wim@linux-watchdog.org>2022-05-21 11:07:32 +0300
commitc83f643878388d468e0a674ac9502d4080499646 (patch)
tree0a5768e5705437fe88aed5555c1b3731178ca7fb /drivers/watchdog/rti_wdt.c
parent95d0eee9718a21ed35fb80a68d3a71759b136f77 (diff)
downloadlinux-c83f643878388d468e0a674ac9502d4080499646.tar.xz
watchdog: rti_wdt: Fix calculation and evaluation of preset heartbeat
This ensures that the same value is read back as was eventually programmed when using seconds as accuracy. Even then, comparing the more precise heartbeat_ms against heartbeat in seconds will almost never provide a match and will needlessly raise a warning. Fix by comparing apples to apples. Tested in combination with U-Boot as watchdog starter. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/6a4b54ac-9588-e172-c4c7-b91d524a851e@siemens.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers/watchdog/rti_wdt.c')
-rw-r--r--drivers/watchdog/rti_wdt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index db843f825860..35f3c396a2ff 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -253,6 +253,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
}
if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
+ int preset_heartbeat;
u32 time_left_ms;
u64 heartbeat_ms;
u32 wsize;
@@ -263,11 +264,12 @@ static int rti_wdt_probe(struct platform_device *pdev)
heartbeat_ms <<= WDT_PRELOAD_SHIFT;
heartbeat_ms *= 1000;
do_div(heartbeat_ms, wdt->freq);
- if (heartbeat_ms != heartbeat * 1000)
+ preset_heartbeat = heartbeat_ms + 500;
+ preset_heartbeat /= 1000;
+ if (preset_heartbeat != heartbeat)
dev_warn(dev, "watchdog already running, ignoring heartbeat config!\n");
- heartbeat = heartbeat_ms;
- heartbeat /= 1000;
+ heartbeat = preset_heartbeat;
wsize = readl(wdt->base + RTIWWDSIZECTRL);
ret = rti_wdt_setup_hw_hb(wdd, wsize);