patch-2.1.76 linux/drivers/char/pcwd.c

Next file: linux/drivers/net/CONFIG
Previous file: linux/drivers/char/mem.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.75/linux/drivers/char/pcwd.c linux/drivers/char/pcwd.c
@@ -31,6 +31,8 @@
  * 970912       Enabled board on open and disable on close.
  * 971107	Took account of recent VFS changes (broke read).
  * 971210       Disable board on initialisation in case board already ticking.
+ * 971222       Changed open/close for temperature handling
+ *              Michael Meskes <meskes@debian.org>.
  */
 
 #include <linux/module.h>
@@ -378,14 +380,23 @@
 
 static int pcwd_open(struct inode *ino, struct file *filep)
 {
-	if (is_open)
-		return -EIO;
-	MOD_INC_USE_COUNT;
-	/*  Enable the port  */
-	if (revision == PCWD_REVISION_C)
-		outb_p(0x00, current_readport + 3);
-	is_open = 1;
-	return(0);
+        switch (MINOR(ino->i_rdev))
+        {
+                case WD_MINOR:
+                    if (is_open)
+                        return -EBUSY;
+                    MOD_INC_USE_COUNT;
+                    /*  Enable the port  */
+                    if (revision == PCWD_REVISION_C)
+                        outb_p(0x00, current_readport + 3);
+                    is_open = 1;
+                    return(0);
+                case TEMP_MINOR:
+                    MOD_INC_USE_COUNT;
+                    return(0);
+                default:
+                    return (-ENODEV);
+        }
 }
 
 static ssize_t pcwd_read(struct file *file, char *buf, size_t count,
@@ -400,7 +411,8 @@
 	switch(MINOR(file->f_dentry->d_inode->i_rdev)) 
 	{
 		case TEMP_MINOR:
-			cp = c;
+		        /* c is in celsius, we need fahrenheit */
+		        cp = (c*9/5)+32;
 			if(copy_to_user(buf, &cp, 1))
 				return -EFAULT;
 			return 1;
@@ -411,15 +423,18 @@
 
 static int pcwd_close(struct inode *ino, struct file *filep)
 {
-	is_open = 0;
 	MOD_DEC_USE_COUNT;
+	if (MINOR(ino->i_rdev)==WD_MINOR)
+	{
+	        is_open = 0;
 #ifndef CONFIG_WATCHDOG_NOWAYOUT
-	/*  Disable the board  */
-	if (revision == PCWD_REVISION_C) {
-		outb_p(0xA5, current_readport + 3);
-		outb_p(0xA5, current_readport + 3);
-	}
+		/*  Disable the board  */
+		if (revision == PCWD_REVISION_C) {
+			outb_p(0xA5, current_readport + 3);
+			outb_p(0xA5, current_readport + 3);
+		}
 #endif
+	}
 	return 0;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov