core: watchdog_set_timeout() doesn't need to return the timeout value used by the HW

The manager currently doesn't need it and if it does in the future an helper
should probably be introduced instead.
This commit is contained in:
Franck Bui
2021-09-06 12:12:06 +02:00
parent ae4a0ec45c
commit 2628b98f0c
6 changed files with 17 additions and 19 deletions

View File

@@ -1539,7 +1539,7 @@ static int become_shutdown(
/* If we reboot or kexec let's set the shutdown watchdog and
* tell the shutdown binary to repeatedly ping it */
r = watchdog_set_timeout(&watchdog_timer);
r = watchdog_set_timeout(watchdog_timer);
watchdog_close(r < 0);
/* Tell the binary how often to ping, ignore failure */

View File

@@ -3205,7 +3205,7 @@ void manager_set_watchdog(Manager *m, WatchdogType t, usec_t timeout) {
if (t == WATCHDOG_RUNTIME)
if (!timestamp_is_set(m->watchdog_overridden[WATCHDOG_RUNTIME])) {
if (timestamp_is_set(timeout))
(void) watchdog_set_timeout(&timeout);
(void) watchdog_set_timeout(timeout);
else
watchdog_close(true);
}
@@ -3224,11 +3224,10 @@ int manager_override_watchdog(Manager *m, WatchdogType t, usec_t timeout) {
return 0;
if (t == WATCHDOG_RUNTIME) {
usec_t *p;
usec_t usec = timestamp_is_set(timeout) ? timeout : m->watchdog[t];
p = timestamp_is_set(timeout) ? &timeout : &m->watchdog[t];
if (timestamp_is_set(*p))
(void) watchdog_set_timeout(p);
if (timestamp_is_set(usec))
(void) watchdog_set_timeout(usec);
else
watchdog_close(true);
}

View File

@@ -96,23 +96,22 @@ int watchdog_set_device(char *path) {
return r;
}
int watchdog_set_timeout(usec_t *usec) {
int r;
int watchdog_set_timeout(usec_t timeout) {
watchdog_timeout = *usec;
/* 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 */
watchdog_timeout = timeout;
/* If we didn't open the watchdog yet and didn't get any explicit timeout value set, don't do
* anything */
/* If we didn't open the watchdog yet and didn't get any explicit
* timeout value set, don't do anything */
if (watchdog_fd < 0 && watchdog_timeout == USEC_INFINITY)
return 0;
if (watchdog_fd < 0)
r = open_watchdog();
else
r = update_timeout();
return open_watchdog();
*usec = watchdog_timeout;
return r;
return update_timeout();
}
usec_t watchdog_runtime_wait(void) {

View File

@@ -7,7 +7,7 @@
#include "util.h"
int watchdog_set_device(char *path);
int watchdog_set_timeout(usec_t *usec);
int watchdog_set_timeout(usec_t timeout);
int watchdog_ping(void);
void watchdog_close(bool disarm);
usec_t watchdog_runtime_wait(void);

View File

@@ -387,7 +387,7 @@ int main(int argc, char *argv[]) {
log_warning_errno(r, "Failed to parse watchdog timeout '%s', ignoring: %m",
watchdog_usec);
else
(void) watchdog_set_timeout(&usec);
(void) watchdog_set_timeout(usec);
}
/* Lock us into memory */

View File

@@ -20,7 +20,7 @@ int main(int argc, char *argv[]) {
t = slow ? 10 * USEC_PER_SEC : 1 * USEC_PER_SEC;
count = slow ? 5 : 3;
r = watchdog_set_timeout(&t);
r = watchdog_set_timeout(t);
if (r < 0)
log_warning_errno(r, "Failed to open watchdog: %m");
if (r == -EPERM)