watchdog: report options in sysfs
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 19 Dec 2022 21:30:40 +0000 (21:30 +0000)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sat, 18 Feb 2023 14:11:40 +0000 (15:11 +0100)
This synchronizes the information reported by ioctl and sysfs.
The mismatch is confusing because "wdctl" from util-linux uses the ioctl
when used with root privileges and sysfs without.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221216-watchdog-sysfs-v2-2-6189311103a9@weissschuh.net
[groeck: Fixed continuation line alignment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Documentation/ABI/testing/sysfs-class-watchdog
drivers/watchdog/watchdog_dev.c

index 27c0002..94fb746 100644 (file)
@@ -6,6 +6,12 @@ Description:
                device at boot. It is equivalent to WDIOC_GETBOOTSTATUS of
                ioctl interface.
 
+What:          /sys/class/watchdog/watchdogn/options
+Date:          April 2023
+Contact:       Thomas Weißschuh
+Description:
+               It is a read only file. It contains options of watchdog device.
+
 What:          /sys/class/watchdog/watchdogn/fw_version
 Date:          April 2023
 Contact:       Thomas Weißschuh
index bd5612f..0122e87 100644 (file)
@@ -547,6 +547,15 @@ static ssize_t pretimeout_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(pretimeout);
 
+static ssize_t options_show(struct device *dev, struct device_attribute *attr,
+                           char *buf)
+{
+       struct watchdog_device *wdd = dev_get_drvdata(dev);
+
+       return sysfs_emit(buf, "0x%x\n", wdd->info->options);
+}
+static DEVICE_ATTR_RO(options);
+
 static ssize_t fw_version_show(struct device *dev, struct device_attribute *attr,
                               char *buf)
 {
@@ -627,6 +636,7 @@ static umode_t wdt_is_visible(struct kobject *kobj, struct attribute *attr,
 }
 static struct attribute *wdt_attrs[] = {
        &dev_attr_state.attr,
+       &dev_attr_options.attr,
        &dev_attr_fw_version.attr,
        &dev_attr_identity.attr,
        &dev_attr_timeout.attr,