Skip to content

Commit b852e7a

Browse files
t-8chWim Van Sebroeck
authored andcommitted
watchdog: report fw_version in sysfs
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 12878a9 commit b852e7a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Documentation/ABI/testing/sysfs-class-watchdog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Description:
66
device at boot. It is equivalent to WDIOC_GETBOOTSTATUS of
77
ioctl interface.
88

9+
What: /sys/class/watchdog/watchdogn/fw_version
10+
Date: April 2023
11+
Contact: Thomas Weißschuh
12+
Description:
13+
It is a read only file. It contains firmware version of
14+
watchdog device.
15+
916
What: /sys/class/watchdog/watchdogn/identity
1017
Date: August 2015
1118
Contact: Wim Van Sebroeck <[email protected]>

drivers/watchdog/watchdog_dev.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,15 @@ static ssize_t pretimeout_show(struct device *dev,
547547
}
548548
static DEVICE_ATTR_RO(pretimeout);
549549

550+
static ssize_t fw_version_show(struct device *dev, struct device_attribute *attr,
551+
char *buf)
552+
{
553+
struct watchdog_device *wdd = dev_get_drvdata(dev);
554+
555+
return sysfs_emit(buf, "%d\n", wdd->info->firmware_version);
556+
}
557+
static DEVICE_ATTR_RO(fw_version);
558+
550559
static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
551560
char *buf)
552561
{
@@ -618,6 +627,7 @@ static umode_t wdt_is_visible(struct kobject *kobj, struct attribute *attr,
618627
}
619628
static struct attribute *wdt_attrs[] = {
620629
&dev_attr_state.attr,
630+
&dev_attr_fw_version.attr,
621631
&dev_attr_identity.attr,
622632
&dev_attr_timeout.attr,
623633
&dev_attr_min_timeout.attr,

0 commit comments

Comments
 (0)