[PATCH 10/10 v2] Generic Watchdog Timer Driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Wim Van Sebroeck <wim@xxxxxxxxx>

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
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux