mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 10/10 v2] Generic Watchdog Timer Driver
@ 2011-06-18 17:28 Wim Van Sebroeck
  2011-06-18 19:10 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Wim Van Sebroeck @ 2011-06-18 17:28 UTC (permalink / raw)
  To: LKML, Linux Watchdog Mailing List; +Cc: Alan Cox

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 10/10 v2] Generic Watchdog Timer Driver
  2011-06-18 17:28 [PATCH 10/10 v2] Generic Watchdog Timer Driver Wim Van Sebroeck
@ 2011-06-18 19:10 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2011-06-18 19:10 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: LKML, Linux Watchdog Mailing List, Alan Cox

On Saturday 18 June 2011 19:28:32 Wim Van Sebroeck wrote:
> 
> 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>

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-18 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-18 17:28 [PATCH 10/10 v2] Generic Watchdog Timer Driver Wim Van Sebroeck
2011-06-18 19:10 ` Arnd Bergmann

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