@@ -485,7 +485,29 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
return sprintf(buf, "%u\n", wdd->timeout);
}
-static DEVICE_ATTR_RO(timeout);
+
+static ssize_t timeout_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned int val;
+ struct watchdog_device *wdd = dev_get_drvdata(dev);
+ struct watchdog_core_data *wd_data = wdd->wd_data;
+
+ ret = kstrtouint(buf, 0, &val);
+ if (ret)
+ return ret;
+
+ mutex_lock(&wd_data->lock);
+ ret = watchdog_set_timeout(wdd, val);
+ mutex_unlock(&wd_data->lock);
+
+ if (!ret)
+ ret = count;
+
+ return ret;
+}
+static DEVICE_ATTR_RW(timeout);
static ssize_t pretimeout_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -494,7 +516,29 @@ static ssize_t pretimeout_show(struct device *dev,
return sprintf(buf, "%u\n", wdd->pretimeout);
}
-static DEVICE_ATTR_RO(pretimeout);
+
+static ssize_t pretimeout_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int ret;
+ unsigned int val;
+ struct watchdog_device *wdd = dev_get_drvdata(dev);
+ struct watchdog_core_data *wd_data = wdd->wd_data;
+
+ ret = kstrtouint(buf, 0, &val);
+ if (ret)
+ return ret;
+
+ mutex_lock(&wd_data->lock);
+ ret = watchdog_set_pretimeout(wdd, val);
+ mutex_unlock(&wd_data->lock);
+
+ if (!ret)
+ ret = count;
+
+ return ret;
+}
+static DEVICE_ATTR_RW(pretimeout);
static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
char *buf)
Those interfaces exist already in sysfs of watchdog driver core, but they are readonly. This patch add write hook so we can config timeout and pretimeout by writing those files. Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com> --- drivers/watchdog/watchdog_dev.c | 48 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)