mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dale Farnsworth" <dale@farnsworth.org>
To: Wim Van Sebroeck <wim@iguana.be>, linux-kernel@vger.kernel.org
Subject: [PATCH 09/11] mv64x60_wdt: Support the WDIOF_MAGICCLOSE feature
Date: Tue, 24 Jul 2007 11:18:14 -0700	[thread overview]
Message-ID: <20070724181813.GI27445@xyzzy.farnsworth.org> (raw)
In-Reply-To: <20070724180738.GA27445@xyzzy.farnsworth.org>

Disallow disabling of the watchdog timer unless a particular
character ('V') was recently written to the watchdog device.

Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
---
 drivers/char/watchdog/mv64x60_wdt.c |   28 ++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

Index: linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c
===================================================================
--- linux-2.6-powerpc-wdt.orig/drivers/char/watchdog/mv64x60_wdt.c	2007-07-20 19:32:41.000000000 +0000
+++ linux-2.6-powerpc-wdt/drivers/char/watchdog/mv64x60_wdt.c	2007-07-20 19:33:30.000000000 +0000
@@ -44,6 +44,7 @@ static int wdt_status;
 static void __iomem *mv64x60_wdt_regs;
 static int mv64x60_wdt_timeout;
 static unsigned int bus_clk;
+static char expect_close;
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
@@ -115,10 +116,14 @@ static int mv64x60_wdt_open(struct inode
 
 static int mv64x60_wdt_release(struct inode *inode, struct file *file)
 {
-	mv64x60_wdt_service();
-
-	if (!nowayout)
+	if (expect_close == 42)
 		mv64x60_wdt_handler_disable();
+	else {
+		printk(KERN_CRIT
+		       "mv64x60_wdt: unexpected close, not stopping timer!\n");
+		mv64x60_wdt_service();
+	}
+	expect_close = 0;
 
 	clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags);
 
@@ -128,8 +133,22 @@ static int mv64x60_wdt_release(struct in
 static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data,
 				 size_t len, loff_t * ppos)
 {
-	if (len)
+	if (len) {
+		if (!nowayout) {
+			size_t i;
+
+			expect_close = 0;
+
+			for (i = 0; i != len; i++) {
+				char c;
+				if(get_user(c, data + i))
+					return -EFAULT;
+				if (c == 'V')
+					expect_close = 42;
+			}
+		}
 		mv64x60_wdt_service();
+	}
 
 	return len;
 }
@@ -142,6 +161,7 @@ static int mv64x60_wdt_ioctl(struct inod
 	void __user *argp = (void __user *)arg;
 	static struct watchdog_info info = {
 		.options =	WDIOF_SETTIMEOUT	|
+				WDIOF_MAGICCLOSE	|
 				WDIOF_KEEPALIVEPING,
 		.firmware_version = 0,
 		.identity = "MV64x60 watchdog",


  parent reply	other threads:[~2007-07-24 18:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24 18:07 [PATCH 01/11] mv64x60_wdt: set up platform_device in platform code Dale Farnsworth
2007-07-24 18:09 ` [PATCH 02/11] mv64x60_wdt: Get register address from platform data Dale Farnsworth
2007-07-24 18:12 ` [PATCH 03/11] mv64x60_wdt: Add arch/powerpc platform support Dale Farnsworth
2007-07-24 18:13 ` [PATCH 04/11] mv64x60_wdt: Check return value of nonseekable_open Dale Farnsworth
2007-07-24 18:14 ` [PATCH 05/11] mv64x60_wdt: Fix WDIOC_GETTIMEOUT return value Dale Farnsworth
2007-07-24 18:15 ` [PATCH 06/11] mv64x60_wdt: Support for WDIOC_SETTIMEOUT ioctl Dale Farnsworth
2007-07-24 18:16 ` [PATCH 07/11] mv64x60_wdt: Add WDIOC_SETOPTIONS ioctl support Dale Farnsworth
2007-07-24 18:17 ` [PATCH 08/11] mv64x60_wdt: Add a module parameter to change nowayout setting Dale Farnsworth
2007-07-24 18:18 ` Dale Farnsworth [this message]
2007-07-24 18:19 ` [PATCH 10/11] mv64x60_wdt: disable watchdog timer when driver is probed Dale Farnsworth
2007-07-24 18:20 ` [PATCH 11/11] mv64x60_wdt_cleanup_low_level_wdt_code.patch Dale Farnsworth
2007-07-24 18:31   ` [PATCH 11/11, corrected] mv64x60_wdt: Rework the timeout register manipulation Dale Farnsworth

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=20070724181813.GI27445@xyzzy.farnsworth.org \
    --to=dale@farnsworth.org \
    --cc=linux-kernel@vger.kernel.org \
    --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