All of lore.kernel.org
 help / color / mirror / Atom feed
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, "Jonathan Corbet" <corbet@lwn.net>,
	"Guenter Roeck" <linux@roeck-us.net>
Subject: [PATCH v5 3/8] watchdog: Make set_timeout function optional
Date: Sun, 22 Nov 2015 19:21:00 -0800	[thread overview]
Message-ID: <1448248865-21684-4-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1448248865-21684-1-git-send-email-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>
---
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 3f0963b2c33e..f480a9355b43 100644
--- a/Documentation/watchdog/watchdog-kernel-api.txt
+++ b/Documentation/watchdog/watchdog-kernel-api.txt
@@ -184,6 +184,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 bb3bd16ffaf6..e73407b42df5 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);
 
-- 
2.1.4


  parent reply	other threads:[~2015-11-23  3:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23  3:20 [PATCH v5 0/8] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck
2015-11-23  3:20 ` [PATCH v5 1/8] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck
2015-11-23  7:53   ` Uwe Kleine-König
2015-11-23 16:14     ` Guenter Roeck
2015-11-23 18:26       ` Uwe Kleine-König
2015-11-23 21:55         ` Guenter Roeck
2015-11-24  7:16   ` Uwe Kleine-König
2015-11-24 15:03     ` Guenter Roeck
2015-11-24 16:11       ` Uwe Kleine-König
2015-11-24 16:45         ` Guenter Roeck
2015-11-24 21:14           ` Uwe Kleine-König
2015-11-23  3:20 ` [PATCH v5 2/8] watchdog: Introduce WDOG_RUNNING flag Guenter Roeck
2015-11-23 16:30   ` Alexander Stein
2015-11-23 16:42     ` Guenter Roeck
2015-11-23 19:26   ` Uwe Kleine-König
2015-11-23 21:48     ` Guenter Roeck
2015-11-23  3:21 ` Guenter Roeck [this message]
2015-11-23  3:21 ` [PATCH v5 4/8] watchdog: Add support for minimum time between heartbeats Guenter Roeck
2015-11-23  3:21 ` [PATCH v5 5/8] watchdog: Simplify update_worker Guenter Roeck
2015-11-24  7:13   ` Uwe Kleine-König
2015-11-24  7:25     ` Guenter Roeck
2015-11-23  3:21 ` [RFT PATCH v5 6/8] watchdog: imx2: Convert to use infrastructure triggered keepalives Guenter Roeck
2015-11-23  3:21 ` [RFT PATCH v5 7/8] watchdog: retu: " Guenter Roeck
2015-11-23  3:21 ` [RFT PATCH v5 8/8] watchdog: at91sam9: " 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=1448248865-21684-4-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=corbet@lwn.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.