From: Guenter Roeck <linux@roeck-us.net>
To: linux-watchdog@vger.kernel.org
Cc: "Wim Van Sebroeck" <wim@iguana.be>,
linux-kernel@vger.kernel.org,
"Timo Kokkonen" <timo.kokkonen@offcode.fi>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
linux-doc@vger.kernel.org,
"Doug Anderson" <dianders@chromium.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH v8 01/10] watchdog: Make set_timeout function optional
Date: Sun, 28 Feb 2016 13:12:14 -0800 [thread overview]
Message-ID: <1456693943-6876-2-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1456693943-6876-1-git-send-email-linux@roeck-us.net>
For some watchdogs, the watchdog driver handles timeout changes without
explicitly setting any registers. 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 <linux@roeck-us.net>
---
v8: Moved to be first patch of series
Rebased to v4.5-rc5
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 | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
index 55120a055a14..dd8f912c0576 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -156,6 +156,11 @@ they are supported. These optional routines/operations are:
because the watchdog does not necessarily has a 1 second resolution).
(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 ba2ecce4aae6..b5e700186ae0 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -183,13 +183,20 @@ static unsigned int watchdog_get_status(struct watchdog_device *wdd)
static int watchdog_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
- if (!wdd->ops->set_timeout || !(wdd->info->options & WDIOF_SETTIMEOUT))
+ int err = 0;
+
+ if (!(wdd->info->options & WDIOF_SETTIMEOUT))
return -EOPNOTSUPP;
if (watchdog_timeout_invalid(wdd, timeout))
return -EINVAL;
- return wdd->ops->set_timeout(wdd, timeout);
+ if (wdd->ops->set_timeout)
+ err = wdd->ops->set_timeout(wdd, timeout);
+ else
+ wdd->timeout = timeout;
+
+ return err;
}
/*
--
2.5.0
next prev parent reply other threads:[~2016-02-28 21:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-28 21:12 [PATCH v8 0/10] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck
2016-02-28 21:12 ` Guenter Roeck [this message]
2016-02-28 21:12 ` [PATCH v8 02/10] watchdog: Introduce hardware maximum heartbeat in watchdog core Guenter Roeck
2016-02-28 21:12 ` [PATCH v8 03/10] watchdog: Introduce WDOG_HW_RUNNING flag Guenter Roeck
2016-02-28 21:12 ` [PATCH v8 04/10] watchdog: Make stop function optional Guenter Roeck
2016-02-28 21:12 ` [PATCH v8 05/10] watchdog: Add support for minimum time between heartbeats Guenter Roeck
2016-02-28 21:12 ` [PATCH v8 06/10] watchdog: dw_wdt: Convert to use watchdog infrastructure Guenter Roeck
2016-03-01 22:59 ` Doug Anderson
2016-03-02 19:39 ` Guenter Roeck
2016-02-28 21:12 ` [PATCH v8 07/10] watchdog: imx2: Convert to use infrastructure triggered keepalives Guenter Roeck
2016-02-28 21:12 ` [RFC PATCH v8 08/10] watchdog: retu: " Guenter Roeck
2016-02-28 21:12 ` [RFC PATCH v8 09/10] watchdog: at91sam9: " Guenter Roeck
2016-02-28 21:12 ` [RFC PATCH v8 10/10] watchdog: gpio: " Guenter Roeck
2016-03-06 10:49 ` [PATCH v8 0/10] watchdog: Add support for keepalives triggered by infrastructure Wim Van Sebroeck
2016-03-07 17:37 ` Guenter Roeck
2016-03-07 18:50 ` Wim Van Sebroeck
2016-03-08 0:39 ` Guenter Roeck
2016-03-07 3:03 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456693943-6876-2-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=corbet@lwn.net \
--cc=dianders@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=timo.kokkonen@offcode.fi \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wim@iguana.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).