aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2011-07-22 14:59:17 -0400
committerWim Van Sebroeck <wim@iguana.be>2011-07-28 04:01:14 -0400
commit7e192b9c4234d29bdc20ac8d0a67edf7624b4206 (patch)
treed46f8208ce67391166e8fbdcc3fe92e6ee01ea3c /drivers/watchdog
parent017cf0805105496ab1880e236cb3e4bf156fb915 (diff)
watchdog: WatchDog Timer Driver Core - Add nowayout feature
Add support for the nowayout feature to the WatchDog Timer Driver Core framework. This feature prevents the watchdog timer from being stopped. 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> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/watchdog_dev.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index db40c6c79ef8..ac20f92347b1 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -98,11 +98,18 @@ static int watchdog_start(struct watchdog_device *wddev)
98 * Stop the watchdog if it is still active and unmark it active. 98 * Stop the watchdog if it is still active and unmark it active.
99 * This function returns zero on success or a negative errno code for 99 * This function returns zero on success or a negative errno code for
100 * failure. 100 * failure.
101 * If the 'nowayout' feature was set, the watchdog cannot be stopped.
101 */ 102 */
102 103
103static int watchdog_stop(struct watchdog_device *wddev) 104static int watchdog_stop(struct watchdog_device *wddev)
104{ 105{
105 int err; 106 int err = -EBUSY;
107
108 if (test_bit(WDOG_NO_WAY_OUT, &wdd->status)) {
109 pr_info("%s: nowayout prevents watchdog to be stopped!\n",
110 wdd->info->identity);
111 return err;
112 }
106 113
107 if (test_bit(WDOG_ACTIVE, &wdd->status)) { 114 if (test_bit(WDOG_ACTIVE, &wdd->status)) {
108 err = wddev->ops->stop(wddev); 115 err = wddev->ops->stop(wddev);
@@ -123,7 +130,7 @@ static int watchdog_stop(struct watchdog_device *wddev)
123 * 130 *
124 * A write to a watchdog device is defined as a keepalive ping. 131 * A write to a watchdog device is defined as a keepalive ping.
125 * Writing the magic 'V' sequence allows the next close to turn 132 * Writing the magic 'V' sequence allows the next close to turn
126 * off the watchdog. 133 * off the watchdog (if 'nowayout' is not set).
127 */ 134 */
128 135
129static ssize_t watchdog_write(struct file *file, const char __user *data, 136static ssize_t watchdog_write(struct file *file, const char __user *data,
@@ -271,8 +278,8 @@ out:
271 * @file: file handle to device 278 * @file: file handle to device
272 * 279 *
273 * This is the code for when /dev/watchdog gets closed. We will only 280 * This is the code for when /dev/watchdog gets closed. We will only
274 * stop the watchdog when we have received the magic char, else the 281 * stop the watchdog when we have received the magic char (and nowayout
275 * watchdog will keep running. 282 * was not set), else the watchdog will keep running.
276 */ 283 */
277 284
278static int watchdog_release(struct inode *inode, struct file *file) 285static int watchdog_release(struct inode *inode, struct file *file)
@@ -281,7 +288,8 @@ static int watchdog_release(struct inode *inode, struct file *file)
281 288
282 /* 289 /*
283 * We only stop the watchdog if we received the magic character 290 * We only stop the watchdog if we received the magic character
284 * or if WDIOF_MAGICCLOSE is not set 291 * or if WDIOF_MAGICCLOSE is not set. If nowayout was set then
292 * watchdog_stop will fail.
285 */ 293 */
286 if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) || 294 if (test_and_clear_bit(WDOG_ALLOW_RELEASE, &wdd->status) ||
287 !(wdd->info->options & WDIOF_MAGICCLOSE)) 295 !(wdd->info->options & WDIOF_MAGICCLOSE))