From 35cc1fac53bbc514ec48e503af94d277b26150e3 Mon Sep 17 00:00:00 2001
From: Wim Van Sebroeck <wim@iguana.be>
Date: Fri, 2 Jan 2004 23:08:45 +0100
Subject: [PATCH] [WATCHDOG] 2.6.0-rc1 - iminor(inode).patch

get rid of unnecessary iminor(inode) code in watchdog's open and close functions.
---
 drivers/char/watchdog/cpu5wdt.c  | 14 ++-------
 drivers/char/watchdog/ib700wdt.c | 44 ++++++++++++----------------
 drivers/char/watchdog/machzwd.c  | 50 ++++++++++++++------------------
 3 files changed, 43 insertions(+), 65 deletions(-)

diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c
index 36897e1ad3e0..bf516d0a1016 100644
--- a/drivers/char/watchdog/cpu5wdt.c
+++ b/drivers/char/watchdog/cpu5wdt.c
@@ -134,23 +134,15 @@ static int cpu5wdt_stop(void)
 
 static int cpu5wdt_open(struct inode *inode, struct file *file)
 {
-	switch(iminor(inode)) {
-		case WATCHDOG_MINOR:
-			if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
-				return -EBUSY;
-			break;
-		default:
-			return -ENODEV;
-	}
+	if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
+		return -EBUSY;
 	return 0;
 
 }
 
 static int cpu5wdt_release(struct inode *inode, struct file *file)
 {
-	if(iminor(inode)==WATCHDOG_MINOR) {
-		clear_bit(0, &cpu5wdt_device.inuse);
-	}
+	clear_bit(0, &cpu5wdt_device.inuse);
 	return 0;
 }
 
diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c
index 6a6289dcc39f..f6030bb8461d 100644
--- a/drivers/char/watchdog/ib700wdt.c
+++ b/drivers/char/watchdog/ib700wdt.c
@@ -217,38 +217,32 @@ ibwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 static int
 ibwdt_open(struct inode *inode, struct file *file)
 {
-	if (iminor(inode) == WATCHDOG_MINOR) {
-		spin_lock(&ibwdt_lock);
-		if (ibwdt_is_open) {
-			spin_unlock(&ibwdt_lock);
-			return -EBUSY;
-		}
-		if (nowayout)
-			__module_get(THIS_MODULE);
-
-		/* Activate */
-		ibwdt_is_open = 1;
-		ibwdt_ping();
+	spin_lock(&ibwdt_lock);
+	if (ibwdt_is_open) {
 		spin_unlock(&ibwdt_lock);
-		return 0;
-	} else {	
-		return -ENODEV;
+		return -EBUSY;
 	}
+	if (nowayout)
+		__module_get(THIS_MODULE);
+
+	/* Activate */
+	ibwdt_is_open = 1;
+	ibwdt_ping();
+	spin_unlock(&ibwdt_lock);
+	return 0;
 }
 
 static int
 ibwdt_close(struct inode *inode, struct file *file)
 {
-	if (iminor(inode) == WATCHDOG_MINOR) {
-		spin_lock(&ibwdt_lock);
-		if (expect_close)
-			outb_p(wd_times[wd_margin], WDT_STOP);
-		else
-			printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
-
-		ibwdt_is_open = 0;
-		spin_unlock(&ibwdt_lock);
-	}
+	spin_lock(&ibwdt_lock);
+	if (expect_close)
+		outb_p(wd_times[wd_margin], WDT_STOP);
+	else
+		printk(KERN_CRIT PFX "WDT device closed unexpectedly.  WDT will not stop!\n");
+
+	ibwdt_is_open = 0;
+	spin_unlock(&ibwdt_lock);
 	return 0;
 }
 
diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
index b46cbda00940..bfa19df72d68 100644
--- a/drivers/char/watchdog/machzwd.c
+++ b/drivers/char/watchdog/machzwd.c
@@ -376,46 +376,38 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
 static int zf_open(struct inode *inode, struct file *file)
 {
-	switch(iminor(inode)){
-		case WATCHDOG_MINOR:
-			spin_lock(&zf_lock);
-			if(zf_is_open){
-				spin_unlock(&zf_lock);
-				return -EBUSY;
-			}
+	spin_lock(&zf_lock);
+	if(zf_is_open){
+		spin_unlock(&zf_lock);
+		return -EBUSY;
+	}
 
-			if (nowayout)
-				__module_get(THIS_MODULE);
+	if (nowayout)
+		__module_get(THIS_MODULE);
 
-			zf_is_open = 1;
+	zf_is_open = 1;
 
-			spin_unlock(&zf_lock);
+	spin_unlock(&zf_lock);
 
-			zf_timer_on();
+	zf_timer_on();
 
-			return 0;
-		default:
-			return -ENODEV;
-	}
+	return 0;
 }
 
 static int zf_close(struct inode *inode, struct file *file)
 {
-	if(iminor(inode) == WATCHDOG_MINOR){
-
-		if(zf_expect_close){
-			zf_timer_off();
-		} else {
-			del_timer(&zf_timer);
-			printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
-		}
+	if(zf_expect_close){
+		zf_timer_off();
+	} else {
+		del_timer(&zf_timer);
+		printk(KERN_ERR PFX ": device file closed unexpectedly. Will not stop the WDT!\n");
+	}
 		
-		spin_lock(&zf_lock);
-		zf_is_open = 0;
-		spin_unlock(&zf_lock);
+	spin_lock(&zf_lock);
+	zf_is_open = 0;
+	spin_unlock(&zf_lock);
 
-		zf_expect_close = 0;
-	}
+	zf_expect_close = 0;
 	
 	return 0;
 }
-- 
2.30.9