watchdog: iTCO_wdt: Update the heartbeat value after clamping timeout
authorZiyan Fu <fuzy5@lenovo.com>
Tue, 29 Apr 2025 10:25:33 +0000 (18:25 +0800)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 1 Jun 2025 11:16:37 +0000 (13:16 +0200)
When executing "modprobe iTCO_wdt heartbeat=700", the user-specified
'heartbeat' parameter exceeds the valid range, the driver clamps the
timeout to default 30s but fails to update the logged 'heartbeat' value,
resulting in misleading log output:

iTCO_wdt iTCO_wdt: timeout value out of range, using 30
iTCO_wdt iTCO_wdt: initialized. heartbeat=700 sec (nowayout=0)

After validating the range, update the 'heartbeat' value with the clamped
timeout value to ensure that log messages accurately reflect the actual
runtime parameters.

Signed-off-by: Ziyan Fu <fuzy5@lenovo.com>
Reviewed-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Link: https://lore.kernel.org/r/20250429102533.11886-1-13281011316@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/iTCO_wdt.c

index 30a8d72..9ab769a 100644 (file)
@@ -580,6 +580,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
                iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT);
                dev_info(dev, "timeout value out of range, using %d\n",
                        WATCHDOG_TIMEOUT);
+               heartbeat = WATCHDOG_TIMEOUT;
        }
 
        watchdog_stop_on_reboot(&p->wddev);