Skip to content

Commit

Permalink
watchdog: report fw_version in sysfs
Browse files Browse the repository at this point in the history
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.

The file is called "fw_version" instead of "firmware_version" as
"firmware_version" is already used as custom attribute by single drivers.

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-1-6189311103a9@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
  • Loading branch information
Thomas Weißschuh authored and Wim Van Sebroeck committed Feb 18, 2023
1 parent 12878a9 commit b852e7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Documentation/ABI/testing/sysfs-class-watchdog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Description:
device at boot. It is equivalent to WDIOC_GETBOOTSTATUS of
ioctl interface.

What: /sys/class/watchdog/watchdogn/fw_version
Date: April 2023
Contact: Thomas Weißschuh
Description:
It is a read only file. It contains firmware version of
watchdog device.

What: /sys/class/watchdog/watchdogn/identity
Date: August 2015
Contact: Wim Van Sebroeck <wim@iguana.be>
Expand Down
10 changes: 10 additions & 0 deletions drivers/watchdog/watchdog_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,15 @@ static ssize_t pretimeout_show(struct device *dev,
}
static DEVICE_ATTR_RO(pretimeout);

static ssize_t fw_version_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct watchdog_device *wdd = dev_get_drvdata(dev);

return sysfs_emit(buf, "%d\n", wdd->info->firmware_version);
}
static DEVICE_ATTR_RO(fw_version);

static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
Expand Down Expand Up @@ -618,6 +627,7 @@ static umode_t wdt_is_visible(struct kobject *kobj, struct attribute *attr,
}
static struct attribute *wdt_attrs[] = {
&dev_attr_state.attr,
&dev_attr_fw_version.attr,
&dev_attr_identity.attr,
&dev_attr_timeout.attr,
&dev_attr_min_timeout.attr,
Expand Down

0 comments on commit b852e7a

Please sign in to comment.