r = watchdog_set_timeout();
if (r < 0) {
if (!ERRNO_IS_NOT_SUPPORTED(r))
- return log_warning_errno(r, "Failed to set timeout to %s, ignoring: %m",
- FORMAT_TIMESPAN(watchdog_timeout, 0));
+ return log_error_errno(r, "Failed to set timeout to %s: %m",
+ FORMAT_TIMESPAN(watchdog_timeout, 0));
log_info("Modifying watchdog timeout is not supported, reusing the programmed timeout.");
watchdog_timeout = USEC_INFINITY;
if (watchdog_timeout == USEC_INFINITY) {
r = watchdog_get_timeout();
if (r < 0)
- return log_warning_errno(errno, "Failed to query watchdog HW timeout, ignoring: %m");
+ return log_error_errno(errno, "Failed to query watchdog HW timeout: %m");
}
r = watchdog_set_enable(true);
static int open_watchdog(void) {
struct watchdog_info ident;
const char *fn;
+ int r;
if (watchdog_fd >= 0)
return 0;
ident.firmware_version,
fn);
- return update_timeout();
+ r = update_timeout();
+ if (r < 0)
+ watchdog_close(true);
+
+ return r;
}
int watchdog_set_device(const char *path) {
}
int watchdog_setup(usec_t timeout) {
+ usec_t previous_timeout;
+ int r;
/* timeout=0 closes the device whereas passing timeout=USEC_INFINITY
* opens it (if needed) without configuring any particular timeout and
/* Initialize the watchdog timeout with the caller value. This value is
* going to be updated by update_timeout() with the closest value
* supported by the driver */
+ previous_timeout = watchdog_timeout;
watchdog_timeout = timeout;
if (watchdog_fd < 0)
return open_watchdog();
- return update_timeout();
+ r = update_timeout();
+ if (r < 0)
+ watchdog_timeout = previous_timeout;
+
+ return r;
}
usec_t watchdog_runtime_wait(void) {