summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/wd_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/wd_core.c')
-rw-r--r--drivers/watchdog/wd_core.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 8b13950238..b6e2a37b1f 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);
@@ -127,6 +135,23 @@ static int watchdog_register_dev(struct watchdog *wd, const char *name, int id)
return register_device(&wd->dev);
}
+/**
+ * dev_get_watchdog_priority() - get a device's desired watchdog priority
+ * @dev: The device, which device_node to read the property from
+ *
+ * return: The priority
+ */
+static unsigned int dev_get_watchdog_priority(struct device_d *dev)
+{
+ unsigned int priority = WATCHDOG_DEFAULT_PRIORITY;
+
+ if (dev)
+ of_property_read_u32(dev->device_node, "watchdog-priority",
+ &priority);
+
+ return priority;
+}
+
int watchdog_register(struct watchdog *wd)
{
struct param_d *p;
@@ -145,8 +170,12 @@ int watchdog_register(struct watchdog *wd)
if (ret)
return ret;
+ p = dev_add_param_tristate_ro(&wd->dev, "running", &wd->running);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
+
if (!wd->priority)
- wd->priority = WATCHDOG_DEFAULT_PRIORITY;
+ wd->priority = dev_get_watchdog_priority(wd->hwdev);
p = dev_add_param_uint32(&wd->dev, "priority",
watchdog_set_priority, NULL,
@@ -232,18 +261,3 @@ struct watchdog *watchdog_get_by_name(const char *name)
return NULL;
}
EXPORT_SYMBOL(watchdog_get_by_name);
-
-/**
- * of_get_watchdog_priority() - get the desired watchdog priority from device tree
- * @node: The device_node to read the property from
- *
- * return: The priority
- */
-unsigned int of_get_watchdog_priority(struct device_node *node)
-{
- unsigned int priority = WATCHDOG_DEFAULT_PRIORITY;
-
- of_property_read_u32(node, "watchdog-priority", &priority);
-
- return priority;
-}