From: Franck Bui Date: Mon, 6 Sep 2021 10:12:45 +0000 (+0200) Subject: watchdog: update watchdog_timeout with the closest timeout found by the driver X-Git-Tag: v250-rc1~670^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=564096795eb385c8216cb67c0fe894edccc39dde;p=thirdparty%2Fsystemd.git watchdog: update watchdog_timeout with the closest timeout found by the driver Store the actual timeout value found by the driver in watchdog_timeout since this value is more accurate for calculating the next time for pinging the device. --- diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index c57dafbca54..c49972c8296 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -40,7 +40,12 @@ static int update_timeout(void) { if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec) < 0) return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec); - log_info("Set hardware watchdog to %s.", FORMAT_TIMESPAN(sec * USEC_PER_SEC, 0)); + /* Just in case the driver is buggy */ + assert(sec > 0); + + /* watchdog_timeout stores the actual timeout used by the HW */ + watchdog_timeout = sec * USEC_PER_SEC; + log_info("Set hardware watchdog to %s.", FORMAT_TIMESPAN(watchdog_timeout, 0)); flags = WDIOS_ENABLECARD; if (ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags) < 0) {