diff options
Diffstat (limited to 'drivers/watchdog/wd_core.c')
-rw-r--r-- | drivers/watchdog/wd_core.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index 39cac6f6c4..fcead11755 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -37,6 +37,8 @@ static const char *watchdog_name(struct watchdog *wd) */ int watchdog_set_timeout(struct watchdog *wd, unsigned timeout) { + int ret; + if (!wd) return -ENODEV; @@ -45,7 +47,13 @@ int watchdog_set_timeout(struct watchdog *wd, unsigned timeout) pr_debug("setting timeout on %s to %ds\n", watchdog_name(wd), timeout); - return wd->set_timeout(wd, timeout); + ret = wd->set_timeout(wd, timeout); + if (ret) + return ret; + + wd->running = timeout ? WDOG_HW_RUNNING : WDOG_HW_NOT_RUNNING; + + return 0; } EXPORT_SYMBOL(watchdog_set_timeout); @@ -144,6 +152,12 @@ static unsigned int dev_get_watchdog_priority(struct device_d *dev) return priority; } +const char *running_names[] = { + [WDOG_HW_RUNNING_UNSUPPORTED] = "unknown", + [WDOG_HW_RUNNING] = "1", + [WDOG_HW_NOT_RUNNING] = "0", +}; + int watchdog_register(struct watchdog *wd) { struct param_d *p; @@ -162,6 +176,11 @@ int watchdog_register(struct watchdog *wd) if (ret) return ret; + p = dev_add_param_enum_ro(&wd->dev, "running", &wd->running, + running_names, ARRAY_SIZE(running_names)); + if (IS_ERR(p)) + return PTR_ERR(p); + if (!wd->priority) wd->priority = dev_get_watchdog_priority(wd->hwdev); |