int watchdog_ping(void) {
usec_t ntime;
- int r;
if (!timestamp_is_set(watchdog_timeout))
return 0;
+ if (watchdog_fd < 0)
+ /* open_watchdog() will automatically ping the device for us if necessary */
+ return open_watchdog();
+
ntime = now(clock_boottime_or_monotonic());
/* Never ping earlier than watchdog_timeout/4 and try to ping
return 0;
}
- if (watchdog_fd < 0) {
- r = open_watchdog();
- if (r < 0)
- return r;
- }
-
if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0)
return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");