mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] watchdog: report all watchdog_ident information via sysfs
@ 2022-12-19 21:30 Thomas Weißschuh
  2022-12-19 21:30 ` [PATCH v2 1/2] watchdog: report fw_version in sysfs Thomas Weißschuh
  2022-12-19 21:30 ` [PATCH v2 2/2] watchdog: report options " Thomas Weißschuh
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2022-12-19 21:30 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-kernel, linux-watchdog, Thomas Weißschuh, Wim Van Sebroeck

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

To: Wim Van Sebroeck <wim@linux-watchdog.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Cc: linux-watchdog@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---

Changes in v2:
- Report options in addition to firmware_version
- Add documentation
- Rename firmware_version to fw_version to avoid conflicts
- Link to v1: https://lore.kernel.org/r/20221214-nsfs-ioctl-compat-v1-0-b169796000b2@weissschuh.net

---
Thomas Weißschuh (2):
      watchdog: report fw_version in sysfs
      watchdog: report options in sysfs

 Documentation/ABI/testing/sysfs-class-watchdog | 13 +++++++++++++
 drivers/watchdog/watchdog_dev.c                | 20 ++++++++++++++++++++
 2 files changed, 33 insertions(+)
---
base-commit: 6feb57c2fd7c787aecf2846a535248899e7b70fa
change-id: 20221216-watchdog-sysfs-b2ce9f8f449b

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] watchdog: report fw_version in sysfs
  2022-12-19 21:30 [PATCH v2 0/2] watchdog: report all watchdog_ident information via sysfs Thomas Weißschuh
@ 2022-12-19 21:30 ` Thomas Weißschuh
  2023-01-31 17:43   ` Guenter Roeck
  2022-12-19 21:30 ` [PATCH v2 2/2] watchdog: report options " Thomas Weißschuh
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Weißschuh @ 2022-12-19 21:30 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-kernel, linux-watchdog, Thomas Weißschuh, Wim Van Sebroeck

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>
---
 Documentation/ABI/testing/sysfs-class-watchdog |  7 +++++++
 drivers/watchdog/watchdog_dev.c                | 10 ++++++++++
 2 files changed, 17 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-watchdog b/Documentation/ABI/testing/sysfs-class-watchdog
index 585caecda3a5..27c000238fe4 100644
--- a/Documentation/ABI/testing/sysfs-class-watchdog
+++ b/Documentation/ABI/testing/sysfs-class-watchdog
@@ -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>
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 55574ed42504..7feeda02a531 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -546,6 +546,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)
 {
@@ -617,6 +626,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,

-- 
2.39.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] watchdog: report options in sysfs
  2022-12-19 21:30 [PATCH v2 0/2] watchdog: report all watchdog_ident information via sysfs Thomas Weißschuh
  2022-12-19 21:30 ` [PATCH v2 1/2] watchdog: report fw_version in sysfs Thomas Weißschuh
@ 2022-12-19 21:30 ` Thomas Weißschuh
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2022-12-19 21:30 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-kernel, linux-watchdog, Thomas Weißschuh, Wim Van Sebroeck

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>
---
 Documentation/ABI/testing/sysfs-class-watchdog |  6 ++++++
 drivers/watchdog/watchdog_dev.c                | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-watchdog b/Documentation/ABI/testing/sysfs-class-watchdog
index 27c000238fe4..94fb74615951 100644
--- a/Documentation/ABI/testing/sysfs-class-watchdog
+++ b/Documentation/ABI/testing/sysfs-class-watchdog
@@ -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
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 7feeda02a531..2b06c179f754 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -546,6 +546,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)
 {
@@ -626,6 +635,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,

-- 
2.39.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] watchdog: report fw_version in sysfs
  2022-12-19 21:30 ` [PATCH v2 1/2] watchdog: report fw_version in sysfs Thomas Weißschuh
@ 2023-01-31 17:43   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2023-01-31 17:43 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Wim Van Sebroeck, linux-kernel, linux-watchdog, Wim Van Sebroeck

On Mon, Dec 19, 2022 at 09:30:39PM +0000, Thomas Weißschuh wrote:
> 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>

> ---
>  Documentation/ABI/testing/sysfs-class-watchdog |  7 +++++++
>  drivers/watchdog/watchdog_dev.c                | 10 ++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-watchdog b/Documentation/ABI/testing/sysfs-class-watchdog
> index 585caecda3a5..27c000238fe4 100644
> --- a/Documentation/ABI/testing/sysfs-class-watchdog
> +++ b/Documentation/ABI/testing/sysfs-class-watchdog
> @@ -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>
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 55574ed42504..7feeda02a531 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -546,6 +546,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)
>  {
> @@ -617,6 +626,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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-31 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 21:30 [PATCH v2 0/2] watchdog: report all watchdog_ident information via sysfs Thomas Weißschuh
2022-12-19 21:30 ` [PATCH v2 1/2] watchdog: report fw_version in sysfs Thomas Weißschuh
2023-01-31 17:43   ` Guenter Roeck
2022-12-19 21:30 ` [PATCH v2 2/2] watchdog: report options " Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®