Skip to content

Commit c83f643

Browse files
jan-kiszkaWim Van Sebroeck
authored andcommitted
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 95d0eee commit c83f643

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/watchdog/rti_wdt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ static int rti_wdt_probe(struct platform_device *pdev)
253253
}
254254

255255
if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
256+
int preset_heartbeat;
256257
u32 time_left_ms;
257258
u64 heartbeat_ms;
258259
u32 wsize;
@@ -263,11 +264,12 @@ static int rti_wdt_probe(struct platform_device *pdev)
263264
heartbeat_ms <<= WDT_PRELOAD_SHIFT;
264265
heartbeat_ms *= 1000;
265266
do_div(heartbeat_ms, wdt->freq);
266-
if (heartbeat_ms != heartbeat * 1000)
267+
preset_heartbeat = heartbeat_ms + 500;
268+
preset_heartbeat /= 1000;
269+
if (preset_heartbeat != heartbeat)
267270
dev_warn(dev, "watchdog already running, ignoring heartbeat config!\n");
268271

269-
heartbeat = heartbeat_ms;
270-
heartbeat /= 1000;
272+
heartbeat = preset_heartbeat;
271273

272274
wsize = readl(wdt->base + RTIWWDSIZECTRL);
273275
ret = rti_wdt_setup_hw_hb(wdd, wsize);

0 commit comments

Comments
 (0)