Skip to contentSkip to conversation

watchdog: Report firmware_version in sysfs

PATCH Superseded Thomas Weißschuh 2 participants 5 messages Nov 25, 2022 – Nov 26, 2022 Watchdog device drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: Report firmware_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.

---

Userspace implementation:

https://github.com/util-linux/util-linux/pull/1927

---
 drivers/watchdog/watchdog_dev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/watchdog/watchdog_dev.c +10 -0
index 55574ed42504..88c76e27873c 100644
@@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(identity);
 
+static ssize_t firmware_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(firmware_version);
+
 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
 				char *buf)
 {
@@ -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_identity.attr,
+	&dev_attr_firmware_version.attr,
 	&dev_attr_timeout.attr,
 	&dev_attr_min_timeout.attr,
 	&dev_attr_max_timeout.attr,

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536

Signature · 1 line
2.38.1
maintainer
#1 lore raw
Quoted 44 lines · Thomas Weißschuh

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.

---

Userspace implementation:

https://github.com/util-linux/util-linux/pull/1927

---
  drivers/watchdog/watchdog_dev.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/watchdog/watchdog_dev.c +10 -0
index 55574ed42504..88c76e27873c 100644
@@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
  }
  static DEVICE_ATTR_RO(identity);
 
+static ssize_t firmware_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(firmware_version);
+
  static ssize_t state_show(struct device *dev, struct device_attribute *attr,
  				char *buf)
  {
@@ -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_identity.attr,
+	&dev_attr_firmware_version.attr,
  	&dev_attr_timeout.attr,
  	&dev_attr_min_timeout.attr,
  	&dev_attr_max_timeout.attr,
Quoted 1 line

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536

I think this conflicts with drivers/watchdog/ziirave_wdt.c which generates its own firmnware_version attribute.

Guenter

#2 lore raw
Quoted 44 lines · Guenter Roeck
Quoted 43 lines · Thomas Weißschuh

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.

---

Userspace implementation:

https://github.com/util-linux/util-linux/pull/1927

---
  drivers/watchdog/watchdog_dev.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
drivers/watchdog/watchdog_dev.c +10 -0
index 55574ed42504..88c76e27873c 100644
@@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
  }
  static DEVICE_ATTR_RO(identity);
+static ssize_t firmware_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(firmware_version);
+
  static ssize_t state_show(struct device *dev, struct device_attribute *attr,
  				char *buf)
  {
@@ -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_identity.attr,
+	&dev_attr_firmware_version.attr,
  	&dev_attr_timeout.attr,
  	&dev_attr_min_timeout.attr,
  	&dev_attr_max_timeout.attr,
Quoted 4 lines
Quoted 1 line

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536

I think this conflicts with drivers/watchdog/ziirave_wdt.c which generates its own firmnware_version attribute.

Indeed, thanks for the catch.

We probably can't change the attribute from ziirave_wdt, which is a bit unfortunate as "firmware_version" would nicely match the name from "struct watchdog_info".

How about "fw_version"?

That would match the naming of sysfs attributes from a bunch of other subsystems.

And obviously an addition to Documentation/ABI/testing/sysfs-class-watchdog is also missing from the patch.
I'll add it in v2.

Thomas

maintainer
#3 lore raw
Quoted 50 lines · Thomas Weißschuh
Quoted 44 lines · Guenter Roeck
Quoted 43 lines · Thomas Weißschuh

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.

---

Userspace implementation:

https://github.com/util-linux/util-linux/pull/1927

---
   drivers/watchdog/watchdog_dev.c | 10 ++++++++++
   1 file changed, 10 insertions(+)
drivers/watchdog/watchdog_dev.c +10 -0
index 55574ed42504..88c76e27873c 100644
@@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
   }
   static DEVICE_ATTR_RO(identity);
+static ssize_t firmware_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(firmware_version);
+
   static ssize_t state_show(struct device *dev, struct device_attribute *attr,
   				char *buf)
   {
@@ -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_identity.attr,
+	&dev_attr_firmware_version.attr,
   	&dev_attr_timeout.attr,
   	&dev_attr_min_timeout.attr,
   	&dev_attr_max_timeout.attr,
Quoted 4 lines
Quoted 1 line

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536

I think this conflicts with drivers/watchdog/ziirave_wdt.c which generates its own firmnware_version attribute.

Quoted 8 lines

Indeed, thanks for the catch.

We probably can't change the attribute from ziirave_wdt, which is a bit unfortunate as "firmware_version" would nicely match the name from "struct watchdog_info".

How about "fw_version"?

I don't have a better idea. Go for it.

Guenter

Quoted 8 lines

That would match the naming of sysfs attributes from a bunch of other subsystems.

And obviously an addition to Documentation/ABI/testing/sysfs-class-watchdog is also missing from the patch.
I'll add it in v2.

Thomas

#4 lore raw
Quoted 53 lines · Guenter Roeck
Quoted 52 lines · Thomas Weißschuh
Quoted 44 lines · Guenter Roeck
Quoted 43 lines · Thomas Weißschuh

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.

---

Userspace implementation:

https://github.com/util-linux/util-linux/pull/1927

---
   drivers/watchdog/watchdog_dev.c | 10 ++++++++++
   1 file changed, 10 insertions(+)
drivers/watchdog/watchdog_dev.c +10 -0
index 55574ed42504..88c76e27873c 100644
@@ -555,6 +555,15 @@ static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
   }
   static DEVICE_ATTR_RO(identity);
+static ssize_t firmware_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(firmware_version);
+
   static ssize_t state_show(struct device *dev, struct device_attribute *attr,
   				char *buf)
   {
@@ -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_identity.attr,
+	&dev_attr_firmware_version.attr,
   	&dev_attr_timeout.attr,
   	&dev_attr_min_timeout.attr,
   	&dev_attr_max_timeout.attr,
Quoted 4 lines
Quoted 1 line

base-commit: 0b1dcc2cf55ae6523c6fbd0d741b3ac28c9f4536

I think this conflicts with drivers/watchdog/ziirave_wdt.c which generates its own firmnware_version attribute.

Indeed, thanks for the catch.

Quoted 8 lines
Quoted 6 lines

We probably can't change the attribute from ziirave_wdt, which is a bit unfortunate as "firmware_version" would nicely match the name from "struct watchdog_info".

How about "fw_version"?

I don't have a better idea. Go for it.

Will do.

Quoted 6 lines
Quoted 6 lines

That would match the naming of sysfs attributes from a bunch of other subsystems.

And obviously an addition to Documentation/ABI/testing/sysfs-class-watchdog is also missing from the patch.
I'll add it in v2.

Can I put you or Wim as contact into the docs?

It feels weird to have a random drive-by contributor listed there.

Thomas