patch-2.3.99-pre3 linux/drivers/char/acquirewdt.c

Next file: linux/drivers/char/amigamouse.c
Previous file: linux/drivers/cdrom/cm206.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre2/linux/drivers/char/acquirewdt.c linux/drivers/char/acquirewdt.c
@@ -37,8 +37,10 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
+#include <linux/spinlock.h>
 
 static int acq_is_open=0;
+static spinlock_t acq_lock;
 
 /*
  *	You must set these - there is no sane way to probe for this board.
@@ -117,8 +119,12 @@
 	switch(MINOR(inode->i_rdev))
 	{
 		case WATCHDOG_MINOR:
+			spin_lock(&acq_lock);
 			if(acq_is_open)
+			{
+				spin_unlock(&acq_lock);
 				return -EBUSY;
+			}
 			MOD_INC_USE_COUNT;
 			/*
 			 *	Activate 
@@ -126,6 +132,7 @@
 	 
 			acq_is_open=1;
 			inb_p(WDT_START);      
+			spin_unlock(&acq_lock);
 			return 0;
 		default:
 			return -ENODEV;
@@ -136,10 +143,12 @@
 {
 	if(MINOR(inode->i_rdev)==WATCHDOG_MINOR)
 	{
+		spin_lock(&acq_lock);
 #ifndef CONFIG_WATCHDOG_NOWAYOUT	
 		inb_p(WDT_STOP);
 #endif		
 		acq_is_open=0;
+		spin_unlock(&acq_lock);
 	}
 	MOD_DEC_USE_COUNT;
 	return 0;
@@ -211,6 +220,7 @@
 {
 	printk("WDT driver for Acquire single board computer initialising.\n");
 
+	spin_lock_init(&acq_lock);
 	misc_register(&acq_miscdev);
 	request_region(WDT_STOP, 1, "Acquire WDT");
 	request_region(WDT_START, 1, "Acquire WDT");

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)