linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: Add {min,max}_timeout sysfs nodes
@ 2021-05-10 13:16 Juerg Haefliger
  2021-05-10 13:45 ` Guenter Roeck
  2021-05-11  6:29 ` [PATCH v2] " Juerg Haefliger
  0 siblings, 2 replies; 6+ messages in thread
From: Juerg Haefliger @ 2021-05-10 13:16 UTC (permalink / raw)
  To: wim, linux, linux-watchdog; +Cc: linux-kernel, Juerg Haefliger

The valid range for the 'timeout' value is useful information so expose
the min and max timeout values via sysfs.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 2946f3a63110..b84d53a79618 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -525,6 +525,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(timeout);
 
+static ssize_t min_timeout_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct watchdog_device *wdd = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%u\n", wdd->min_timeout);
+}
+static DEVICE_ATTR_RO(min_timeout);
+
+static ssize_t max_timeout_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct watchdog_device *wdd = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%u\n", wdd->max_timeout);
+}
+static DEVICE_ATTR_RO(max_timeout);
+
 static ssize_t pretimeout_show(struct device *dev,
 			       struct device_attribute *attr, char *buf)
 {
@@ -609,6 +627,8 @@ static struct attribute *wdt_attrs[] = {
 	&dev_attr_state.attr,
 	&dev_attr_identity.attr,
 	&dev_attr_timeout.attr,
+	&dev_attr_min_timeout.attr,
+	&dev_attr_max_timeout.attr,
 	&dev_attr_pretimeout.attr,
 	&dev_attr_timeleft.attr,
 	&dev_attr_bootstatus.attr,
-- 
2.27.0


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

* Re: [PATCH] watchdog: Add {min,max}_timeout sysfs nodes
  2021-05-10 13:16 [PATCH] watchdog: Add {min,max}_timeout sysfs nodes Juerg Haefliger
@ 2021-05-10 13:45 ` Guenter Roeck
  2021-05-10 14:14   ` Juerg Haefliger
  2021-05-11  6:29 ` [PATCH v2] " Juerg Haefliger
  1 sibling, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2021-05-10 13:45 UTC (permalink / raw)
  To: Juerg Haefliger, wim, linux-watchdog; +Cc: linux-kernel, Juerg Haefliger

On 5/10/21 6:16 AM, Juerg Haefliger wrote:
> The valid range for the 'timeout' value is useful information so expose
> the min and max timeout values via sysfs.
> 
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>   drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 2946f3a63110..b84d53a79618 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -525,6 +525,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
>   }
>   static DEVICE_ATTR_RO(timeout);
>   
> +static ssize_t min_timeout_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%u\n", wdd->min_timeout);
> +}
> +static DEVICE_ATTR_RO(min_timeout);
> +
> +static ssize_t max_timeout_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> +	return sprintf(buf, "%u\n", wdd->max_timeout);

Makes sense, but please use sysfs_emit().

Guenter

> +}
> +static DEVICE_ATTR_RO(max_timeout);
> +
>   static ssize_t pretimeout_show(struct device *dev,
>   			       struct device_attribute *attr, char *buf)
>   {
> @@ -609,6 +627,8 @@ static struct attribute *wdt_attrs[] = {
>   	&dev_attr_state.attr,
>   	&dev_attr_identity.attr,
>   	&dev_attr_timeout.attr,
> +	&dev_attr_min_timeout.attr,
> +	&dev_attr_max_timeout.attr,
>   	&dev_attr_pretimeout.attr,
>   	&dev_attr_timeleft.attr,
>   	&dev_attr_bootstatus.attr,
> 


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

* Re: [PATCH] watchdog: Add {min,max}_timeout sysfs nodes
  2021-05-10 13:45 ` Guenter Roeck
@ 2021-05-10 14:14   ` Juerg Haefliger
  2021-05-10 14:56     ` Guenter Roeck
  0 siblings, 1 reply; 6+ messages in thread
From: Juerg Haefliger @ 2021-05-10 14:14 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Juerg Haefliger, wim, linux-watchdog, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2051 bytes --]

On Mon, 10 May 2021 06:45:15 -0700
Guenter Roeck <linux@roeck-us.net> wrote:

> On 5/10/21 6:16 AM, Juerg Haefliger wrote:
> > The valid range for the 'timeout' value is useful information so expose
> > the min and max timeout values via sysfs.
> > 
> > Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> > ---
> >   drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
> >   1 file changed, 20 insertions(+)
> > 
> > diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> > index 2946f3a63110..b84d53a79618 100644
> > --- a/drivers/watchdog/watchdog_dev.c
> > +++ b/drivers/watchdog/watchdog_dev.c
> > @@ -525,6 +525,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
> >   }
> >   static DEVICE_ATTR_RO(timeout);
> >   
> > +static ssize_t min_timeout_show(struct device *dev,
> > +				struct device_attribute *attr, char *buf)
> > +{
> > +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> > +
> > +	return sprintf(buf, "%u\n", wdd->min_timeout);
> > +}
> > +static DEVICE_ATTR_RO(min_timeout);
> > +
> > +static ssize_t max_timeout_show(struct device *dev,
> > +				struct device_attribute *attr, char *buf)
> > +{
> > +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> > +
> > +	return sprintf(buf, "%u\n", wdd->max_timeout);  
> 
> Makes sense, but please use sysfs_emit().

OK. And maybe I should send a patch to convert the other occurrences of
sprintf as well?

...Juerg


> Guenter
> 
> > +}
> > +static DEVICE_ATTR_RO(max_timeout);
> > +
> >   static ssize_t pretimeout_show(struct device *dev,
> >   			       struct device_attribute *attr, char *buf)
> >   {
> > @@ -609,6 +627,8 @@ static struct attribute *wdt_attrs[] = {
> >   	&dev_attr_state.attr,
> >   	&dev_attr_identity.attr,
> >   	&dev_attr_timeout.attr,
> > +	&dev_attr_min_timeout.attr,
> > +	&dev_attr_max_timeout.attr,
> >   	&dev_attr_pretimeout.attr,
> >   	&dev_attr_timeleft.attr,
> >   	&dev_attr_bootstatus.attr,
> >   
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] watchdog: Add {min,max}_timeout sysfs nodes
  2021-05-10 14:14   ` Juerg Haefliger
@ 2021-05-10 14:56     ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2021-05-10 14:56 UTC (permalink / raw)
  To: Juerg Haefliger; +Cc: wim, linux-watchdog, linux-kernel

On 5/10/21 7:14 AM, Juerg Haefliger wrote:
> On Mon, 10 May 2021 06:45:15 -0700
> Guenter Roeck <linux@roeck-us.net> wrote:
> 
>> On 5/10/21 6:16 AM, Juerg Haefliger wrote:
>>> The valid range for the 'timeout' value is useful information so expose
>>> the min and max timeout values via sysfs.
>>>
>>> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
>>> ---
>>>    drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
>>>    1 file changed, 20 insertions(+)
>>>
>>> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
>>> index 2946f3a63110..b84d53a79618 100644
>>> --- a/drivers/watchdog/watchdog_dev.c
>>> +++ b/drivers/watchdog/watchdog_dev.c
>>> @@ -525,6 +525,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
>>>    }
>>>    static DEVICE_ATTR_RO(timeout);
>>>    
>>> +static ssize_t min_timeout_show(struct device *dev,
>>> +				struct device_attribute *attr, char *buf)
>>> +{
>>> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
>>> +
>>> +	return sprintf(buf, "%u\n", wdd->min_timeout);
>>> +}
>>> +static DEVICE_ATTR_RO(min_timeout);
>>> +
>>> +static ssize_t max_timeout_show(struct device *dev,
>>> +				struct device_attribute *attr, char *buf)
>>> +{
>>> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
>>> +
>>> +	return sprintf(buf, "%u\n", wdd->max_timeout);
>>
>> Makes sense, but please use sysfs_emit().
> 
> OK. And maybe I should send a patch to convert the other occurrences of
> sprintf as well?
> 

Sure, if you want to.

Guenter

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

* [PATCH v2] watchdog: Add {min,max}_timeout sysfs nodes
  2021-05-10 13:16 [PATCH] watchdog: Add {min,max}_timeout sysfs nodes Juerg Haefliger
  2021-05-10 13:45 ` Guenter Roeck
@ 2021-05-11  6:29 ` Juerg Haefliger
  2021-05-11 13:35   ` Guenter Roeck
  1 sibling, 1 reply; 6+ messages in thread
From: Juerg Haefliger @ 2021-05-11  6:29 UTC (permalink / raw)
  To: wim, linux, linux-watchdog; +Cc: linux-kernel, Juerg Haefliger

The valid range for the 'timeout' value is useful information so expose
the min and max timeout values via sysfs.

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---

v1->v2:
 - replace sprintf() with sysfs_emit().

 drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index fe68a97973a5..7c1007ab1b71 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -526,6 +526,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(timeout);
 
+static ssize_t min_timeout_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct watchdog_device *wdd = dev_get_drvdata(dev);
+
+	return sysfs_emit(buf, "%u\n", wdd->min_timeout);
+}
+static DEVICE_ATTR_RO(min_timeout);
+
+static ssize_t max_timeout_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct watchdog_device *wdd = dev_get_drvdata(dev);
+
+	return sysfs_emit(buf, "%u\n", wdd->max_timeout);
+}
+static DEVICE_ATTR_RO(max_timeout);
+
 static ssize_t pretimeout_show(struct device *dev,
 			       struct device_attribute *attr, char *buf)
 {
@@ -610,6 +628,8 @@ static struct attribute *wdt_attrs[] = {
 	&dev_attr_state.attr,
 	&dev_attr_identity.attr,
 	&dev_attr_timeout.attr,
+	&dev_attr_min_timeout.attr,
+	&dev_attr_max_timeout.attr,
 	&dev_attr_pretimeout.attr,
 	&dev_attr_timeleft.attr,
 	&dev_attr_bootstatus.attr,
-- 
2.27.0


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

* Re: [PATCH v2] watchdog: Add {min,max}_timeout sysfs nodes
  2021-05-11  6:29 ` [PATCH v2] " Juerg Haefliger
@ 2021-05-11 13:35   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2021-05-11 13:35 UTC (permalink / raw)
  To: Juerg Haefliger, wim, linux-watchdog; +Cc: linux-kernel, Juerg Haefliger

On 5/10/21 11:29 PM, Juerg Haefliger wrote:
> The valid range for the 'timeout' value is useful information so expose
> the min and max timeout values via sysfs.
> 
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> v1->v2:
>   - replace sprintf() with sysfs_emit().
> 
>   drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index fe68a97973a5..7c1007ab1b71 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -526,6 +526,24 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
>   }
>   static DEVICE_ATTR_RO(timeout);
>   
> +static ssize_t min_timeout_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> +	return sysfs_emit(buf, "%u\n", wdd->min_timeout);
> +}
> +static DEVICE_ATTR_RO(min_timeout);
> +
> +static ssize_t max_timeout_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	struct watchdog_device *wdd = dev_get_drvdata(dev);
> +
> +	return sysfs_emit(buf, "%u\n", wdd->max_timeout);
> +}
> +static DEVICE_ATTR_RO(max_timeout);
> +
>   static ssize_t pretimeout_show(struct device *dev,
>   			       struct device_attribute *attr, char *buf)
>   {
> @@ -610,6 +628,8 @@ static struct attribute *wdt_attrs[] = {
>   	&dev_attr_state.attr,
>   	&dev_attr_identity.attr,
>   	&dev_attr_timeout.attr,
> +	&dev_attr_min_timeout.attr,
> +	&dev_attr_max_timeout.attr,
>   	&dev_attr_pretimeout.attr,
>   	&dev_attr_timeleft.attr,
>   	&dev_attr_bootstatus.attr,
> 


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

end of thread, other threads:[~2021-05-11 13:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 13:16 [PATCH] watchdog: Add {min,max}_timeout sysfs nodes Juerg Haefliger
2021-05-10 13:45 ` Guenter Roeck
2021-05-10 14:14   ` Juerg Haefliger
2021-05-10 14:56     ` Guenter Roeck
2021-05-11  6:29 ` [PATCH v2] " Juerg Haefliger
2021-05-11 13:35   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).