mirror of https://lore.kernel.org/lkml/
 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 v4 1/9] watchdog: Always evaluate new timeout against min_timeout
Date: Tue, 29 Sep 2015 01:27:24 -0700	[thread overview]
Message-ID: <1443515252-30085-2-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1443515252-30085-1-git-send-email-linux@roeck-us.net>

Up to now, a new timeout value is only evaluated against min_timeout
if max_timeout is provided. This does not really make sense; a driver
can have a minimum timeout even if it does not have a maximum timeout.
Ensure that it is not smaller than min_timeout, even if max_timeout
is not set.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v4: Now first patch of series.
    Added comments.
v3: New patch.
---
 include/linux/watchdog.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index d74a0e907b9e..e90e3ea5ebeb 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -119,8 +119,15 @@ static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool noway
 /* Use the following function to check if a timeout value is invalid */
 static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigned int t)
 {
-	return ((wdd->max_timeout != 0) &&
-		(t < wdd->min_timeout || t > wdd->max_timeout));
+	/*
+	 * The timeout is invalid if
+	 * - the requested value is smaller than the configured minimum timeout,
+	 * or
+	 * - a maximum timeout is configured, and the requested value is larger
+	 *   than the maximum timeout.
+	 */
+	return t < wdd->min_timeout ||
+		(wdd->max_timeout && t > wdd->max_timeout);
 }
 
 /* Use the following functions to manipulate watchdog driver specific data */
-- 
2.1.4


  reply	other threads:[~2015-09-29  8:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29  8:27 [PATCH v4 0/9] watchdog: Add support for keepalives triggered by infrastructure Guenter Roeck
2015-09-29  8:27 ` Guenter Roeck [this message]
2015-09-29  8:51   ` [PATCH v4 1/9] watchdog: Always evaluate new timeout against min_timeout Uwe Kleine-König
2015-09-29  8:27 ` [PATCH v4 2/9] watchdog: watchdog_dev: Use single variable name for struct watchdog_device Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 3/9] watchdog: Introduce hardware maximum timeout in watchdog core Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 4/9] watchdog: Introduce WDOG_RUNNING flag Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 5/9] watchdog: Make set_timeout function optional Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 6/9] watchdog: imx2: Convert to use infrastructure triggered keepalives Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 7/9] watchdog: retu: " Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 8/9] watchdog: at91sam9: " Guenter Roeck
2015-09-29  8:27 ` [PATCH v4 9/9] watchdog: Add support for minimum time between heartbeats 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=1443515252-30085-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome