Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1317493
| From | Guenter Roeck <patchwork@patchwork.roeck-us.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v7 3/9] watchdog: Make set_timeout function optional |
| Date | 2016-01-26 04:00 +0100 |
| Message-ID | <qV21k-4Zc-13@gated-at.bofh.it> (permalink) |
| References | <qV21j-4Zc-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Guenter Roeck <linux@roeck-us.net>
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.
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v7: Rebased to v4.5-rc1
v6: Rebased to v4.4-rc2
v5: Rebased to v4.4-rc1
v4: No changes
v3: No changes
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 738bd6809328..62d49d6a7ff5 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -175,6 +175,11 @@ they are supported. These optional routines/operations are:
(if it is larger than max_hw_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.
* restart: this routine restarts the machine. It returns 0 on success or a
negative errno code for failure.
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 469b13b8363b..1a8f3861fe92 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -288,15 +288,18 @@ static unsigned int watchdog_get_status(struct watchdog_device *wdd)
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))
return -EINVAL;
- 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);
--
2.1.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v7 0/9] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[RFT PATCH v7 7/9] watchdog: retu: Convert to use infrastructure triggered keepalives Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[RFT PATCH v7 8/9] watchdog: at91sam9: Convert to use infrastructure triggered keepalives Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[PATCH v7 1/9] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[RFT PATCH v7 9/9] watchdog: dw_wdt: Convert to use watchdog infrastructure Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[PATCH v7 3/9] watchdog: Make set_timeout function optional Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[PATCH v7 5/9] watchdog: Simplify update_worker Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[PATCH v7 2/9] watchdog: Introduce WDOG_HW_RUNNING flag Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
[PATCH v7 4/9] watchdog: Add support for minimum time between heartbeats Guenter Roeck <patchwork@patchwork.roeck-us.net> - 2016-01-26 04:00 +0100
Re: [PATCH v7 4/9] watchdog: Add support for minimum time between heartbeats Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2016-01-26 09:10 +0100
Re: [PATCH v7 4/9] watchdog: Add support for minimum time between heartbeats Guenter Roeck <linux@roeck-us.net> - 2016-01-26 15:50 +0100
Re: [PATCH v7 0/9] watchdog: Add support for keepalives triggered by infrastructure Uwe Kleine-König <u.kleine-koenig@pengutronix.de> - 2016-01-26 09:10 +0100
Re: [PATCH v7 0/9] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck <linux@roeck-us.net> - 2016-01-26 15:50 +0100
csiph-web