mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wim Van Sebroeck <wim@iguana.be>
To: LKML <linux-kernel@vger.kernel.org>,
	Linux Watchdog Mailing List <linux-watchdog@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [PATCH 10/10 v2] Generic Watchdog Timer Driver
Date: Sat, 18 Jun 2011 19:28:32 +0200	[thread overview]
Message-ID: <20110618172832.GK3441@infomag.iguana.be> (raw)

watchdog: WatchDog Timer Driver Core - Part 10

Add min_timeout (minimum timeout) and max_timeout
values so that the framework can check if the new
timeout value is between the minimum and maximum
timeout values. If both values are 0, then the
framework will leave the check for the watchdog
device driver itself.

Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

diff -urN linux-2.6.38-generic-part9/Documentation/watchdog/watchdog-kernel-api.txt linux-2.6.38-generic-partA/Documentation/watchdog/watchdog-kernel-api.txt
--- linux-2.6.38-generic-part9/Documentation/watchdog/watchdog-kernel-api.txt	2011-06-17 10:14:55.514632632 +0200
+++ linux-2.6.38-generic-partA/Documentation/watchdog/watchdog-kernel-api.txt	2011-06-17 12:20:35.765063301 +0200
@@ -44,6 +44,8 @@
 	const struct watchdog_ops *ops;
 	struct device *parent;
 	int timeout;
+	int min_timeout;
+	int max_timeout;
 	int bootstatus;
 	long status;
 };
@@ -56,6 +58,8 @@
 * parent: a pointer to the parent device of the watchdog. This will be set
   as the parent of the misc device.
 * timeout: the watchdog timer's timeout value (in seconds).
+* min_timeout: the watchdog timer's minimum timeout value (in seconds).
+* max_timeout: the watchdog timer's maximum timeout value (in seconds).
 * bootstatus: status of the device after booting (reported with watchdog
   WDIOF_* status bits).
 * status: this field contains a number of status bits that give extra
diff -urN linux-2.6.38-generic-part9/drivers/watchdog/core/watchdog_core.c linux-2.6.38-generic-partA/drivers/watchdog/core/watchdog_core.c
--- linux-2.6.38-generic-part9/drivers/watchdog/core/watchdog_core.c	2011-06-16 19:35:42.731177562 +0200
+++ linux-2.6.38-generic-partA/drivers/watchdog/core/watchdog_core.c	2011-06-17 13:43:20.661062411 +0200
@@ -66,6 +66,13 @@
 	if (wdd->ops->start == NULL || wdd->ops->stop == NULL)
 		return -ENODATA;
 
+	/* Check that we have valid min and max timeout values, if
+	 * not reset them both to 0 (=not used or unknown) */
+	if (wdd->min_timeout > wdd->max_timeout) {
+		wdd->min_timeout = 0;
+		wdd->max_timeout = 0;
+	}
+
 	/* Note: now that all watchdog_device data has been verified, we
 	 * will not check this anymore in other functions. If data get's
 	 * corrupted in a later stage then we expect a kernel panic! */
diff -urN linux-2.6.38-generic-part9/drivers/watchdog/core/watchdog_dev.c linux-2.6.38-generic-partA/drivers/watchdog/core/watchdog_dev.c
--- linux-2.6.38-generic-part9/drivers/watchdog/core/watchdog_dev.c	2011-06-17 10:14:55.522632632 +0200
+++ linux-2.6.38-generic-partA/drivers/watchdog/core/watchdog_dev.c	2011-06-17 13:48:31.493062339 +0200
@@ -250,6 +250,9 @@
 			return -EOPNOTSUPP;
 		if (get_user(val, p))
 			return -EFAULT;
+		if ((wdd->max_timeout != 0) &&
+		    (val < wdd->min_timeout || val > wdd->max_timeout))
+				return -EINVAL;
 		err = wdd->ops->set_timeout(wdd, val);
 		if (err < 0)
 			return err;
diff -urN linux-2.6.38-generic-part9/include/linux/watchdog.h linux-2.6.38-generic-partA/include/linux/watchdog.h
--- linux-2.6.38-generic-part9/include/linux/watchdog.h	2011-06-17 12:18:05.261063514 +0200
+++ linux-2.6.38-generic-partA/include/linux/watchdog.h	2011-06-17 12:19:20.637064105 +0200
@@ -83,6 +83,8 @@
 	struct device *parent;
 	int bootstatus;
 	int timeout;
+	int min_timeout;
+	int max_timeout;
 	long status;
 #define WDOG_ACTIVE		0	/* is the watchdog running/active */
 #define WDOG_DEV_OPEN		1	/* is the watchdog opened via

             reply	other threads:[~2011-06-18 17:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-18 17:28 Wim Van Sebroeck [this message]
2011-06-18 19:10 ` Arnd Bergmann

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=20110618172832.GK3441@infomag.iguana.be \
    --to=wim@iguana.be \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®