Re: [PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-15 Thread Guenter Roeck

Hi Uwe,

On 08/14/2015 12:05 PM, Uwe Kleine-König wrote:

Hello Guenter,

On Fri, Aug 07, 2015 at 10:02:43PM -0700, Guenter Roeck wrote:

For some watchdogs, the hardware timeout is fixed, and the
watchdog driver depends on the watchdog core to handle the
actual timeout. In this situation, the watchdog driver might
only set the 'timeout' variable but do nothing else.
This can as well be handled by the infrastructure, so make
the set_timeout callback optional. If WDIOF_SETTIMEOUT is
configured but the .set_timeout callback is not available,
update the timeout variable in the infrastructure code.

Signed-off-by: Guenter Roeck 

Acked-by: Uwe Kleine-König 



Thanks!
Guenter


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-15 Thread Guenter Roeck

Hi Uwe,

On 08/14/2015 12:05 PM, Uwe Kleine-König wrote:

Hello Guenter,

On Fri, Aug 07, 2015 at 10:02:43PM -0700, Guenter Roeck wrote:

For some watchdogs, the hardware timeout is fixed, and the
watchdog driver depends on the watchdog core to handle the
actual timeout. In this situation, the watchdog driver might
only set the 'timeout' variable but do nothing else.
This can as well be handled by the infrastructure, so make
the set_timeout callback optional. If WDIOF_SETTIMEOUT is
configured but the .set_timeout callback is not available,
update the timeout variable in the infrastructure code.

Signed-off-by: Guenter Roeck li...@roeck-us.net

Acked-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de



Thanks!
Guenter


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-14 Thread Uwe Kleine-König
Hello Guenter,

On Fri, Aug 07, 2015 at 10:02:43PM -0700, Guenter Roeck wrote:
> For some watchdogs, the hardware timeout is fixed, and the
> watchdog driver depends on the watchdog core to handle the
> actual timeout. In this situation, the watchdog driver might
> only set the 'timeout' variable but do nothing else.
> This can as well be handled by the infrastructure, so make
> the set_timeout callback optional. If WDIOF_SETTIMEOUT is
> configured but the .set_timeout callback is not available,
> update the timeout variable in the infrastructure code.
> 
> Signed-off-by: Guenter Roeck 
Acked-by: Uwe Kleine-König 

Thanks
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-14 Thread Uwe Kleine-König
Hello Guenter,

On Fri, Aug 07, 2015 at 10:02:43PM -0700, Guenter Roeck wrote:
 For some watchdogs, the hardware timeout is fixed, and the
 watchdog driver depends on the watchdog core to handle the
 actual timeout. In this situation, the watchdog driver might
 only set the 'timeout' variable but do nothing else.
 This can as well be handled by the infrastructure, so make
 the set_timeout callback optional. If WDIOF_SETTIMEOUT is
 configured but the .set_timeout callback is not available,
 update the timeout variable in the infrastructure code.
 
 Signed-off-by: Guenter Roeck li...@roeck-us.net
Acked-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de

Thanks
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-07 Thread Guenter Roeck
For some watchdogs, the hardware timeout is fixed, and the
watchdog driver depends on the watchdog core to handle the
actual timeout. In this situation, the watchdog driver might
only set the 'timeout' variable but do nothing else.
This can as well be handled by the infrastructure, so make
the set_timeout callback optional. If WDIOF_SETTIMEOUT is
configured but the .set_timeout callback is not available,
update the timeout variable in the infrastructure code.

Signed-off-by: Guenter Roeck 
---
v2: No changes
---
 Documentation/watchdog/watchdog-kernel-api.txt | 5 +
 drivers/watchdog/watchdog_dev.c| 9 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/watchdog/watchdog-kernel-api.txt 
b/Documentation/watchdog/watchdog-kernel-api.txt
index 6a54dc15a556..49dce3a5477b 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -181,6 +181,11 @@ they are supported. These optional routines/operations are:
   (if it is larger than hw_max_timeout_ms), or to the achieved timeout value.
   (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the
   watchdog's info structure).
+  If the watchdog driver does not have to perform any action but setting the
+  watchdog_device.timeout, this callback can be omitted.
+  If set_timeout is not provided but, WDIOF_SETTIMEOUT is set, the watchdog
+  infrastructure updates the timeout value of the watchdog_device internally
+  to the requested value.
 * get_timeleft: this routines returns the time that's left before a reset.
 * ref: the operation that calls kref_get on the kref of a dynamically
   allocated watchdog_device struct.
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 676e233d5e7b..752de264a244 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -282,9 +282,9 @@ out_status:
 static int watchdog_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
 {
-   int err;
+   int err = 0;
 
-   if (!wdd->ops->set_timeout || !(wdd->info->options & WDIOF_SETTIMEOUT))
+   if (!(wdd->info->options & WDIOF_SETTIMEOUT))
return -EOPNOTSUPP;
 
if (watchdog_timeout_invalid(wdd, timeout))
@@ -297,7 +297,10 @@ static int watchdog_set_timeout(struct watchdog_device 
*wdd,
goto out_timeout;
}
 
-   err = wdd->ops->set_timeout(wdd, timeout);
+   if (wdd->ops->set_timeout)
+   err = wdd->ops->set_timeout(wdd, timeout);
+   else
+   wdd->timeout = timeout;
 
watchdog_update_worker(wdd, true, false);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 4/8] watchdog: Make set_timeout function optional

2015-08-07 Thread Guenter Roeck
For some watchdogs, the hardware timeout is fixed, and the
watchdog driver depends on the watchdog core to handle the
actual timeout. In this situation, the watchdog driver might
only set the 'timeout' variable but do nothing else.
This can as well be handled by the infrastructure, so make
the set_timeout callback optional. If WDIOF_SETTIMEOUT is
configured but the .set_timeout callback is not available,
update the timeout variable in the infrastructure code.

Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v2: No changes
---
 Documentation/watchdog/watchdog-kernel-api.txt | 5 +
 drivers/watchdog/watchdog_dev.c| 9 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/watchdog/watchdog-kernel-api.txt 
b/Documentation/watchdog/watchdog-kernel-api.txt
index 6a54dc15a556..49dce3a5477b 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -181,6 +181,11 @@ they are supported. These optional routines/operations are:
   (if it is larger than hw_max_timeout_ms), or to the achieved timeout value.
   (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the
   watchdog's info structure).
+  If the watchdog driver does not have to perform any action but setting the
+  watchdog_device.timeout, this callback can be omitted.
+  If set_timeout is not provided but, WDIOF_SETTIMEOUT is set, the watchdog
+  infrastructure updates the timeout value of the watchdog_device internally
+  to the requested value.
 * get_timeleft: this routines returns the time that's left before a reset.
 * ref: the operation that calls kref_get on the kref of a dynamically
   allocated watchdog_device struct.
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 676e233d5e7b..752de264a244 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -282,9 +282,9 @@ out_status:
 static int watchdog_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
 {
-   int err;
+   int err = 0;
 
-   if (!wdd-ops-set_timeout || !(wdd-info-options  WDIOF_SETTIMEOUT))
+   if (!(wdd-info-options  WDIOF_SETTIMEOUT))
return -EOPNOTSUPP;
 
if (watchdog_timeout_invalid(wdd, timeout))
@@ -297,7 +297,10 @@ static int watchdog_set_timeout(struct watchdog_device 
*wdd,
goto out_timeout;
}
 
-   err = wdd-ops-set_timeout(wdd, timeout);
+   if (wdd-ops-set_timeout)
+   err = wdd-ops-set_timeout(wdd, timeout);
+   else
+   wdd-timeout = timeout;
 
watchdog_update_worker(wdd, true, false);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/