patch-2.4.0-test2 linux/drivers/char/busmouse.c

Next file: linux/drivers/char/busmouse.h
Previous file: linux/drivers/char/bttv.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/drivers/char/busmouse.c linux/drivers/char/busmouse.c
@@ -110,8 +110,7 @@
 	if (changed) {
 		wake_up(&mse->wait);
 
-		if (mse->fasyncptr)
-			kill_fasync(mse->fasyncptr, SIGIO, POLL_IN);
+		kill_fasync(&mse->fasyncptr, SIGIO, POLL_IN);
 	}
 }
 
@@ -171,13 +170,13 @@
 	busmouse_fasync(-1, file, 0);
 
 	if (--mse->active == 0) {
-		if (mse->ops &&
-		    mse->ops->release)
-			ret = mse->ops->release(inode, file);
-
+		if (mse->ops) {
+			if (mse->ops->release)
+				ret = mse->ops->release(inode, file);
+		   	if (mse->ops->owner)
+				__MOD_DEC_USE_COUNT(mse->ops->owner);
+		}
 		mse->ready = 0;
-
-		MOD_DEC_USE_COUNT;
 	}
 
 	return ret;
@@ -192,16 +191,20 @@
 	mousedev = DEV_TO_MOUSE(inode->i_rdev);
 	if (mousedev >= NR_MICE)
 		return -EINVAL;
-	
+
 	down(&mouse_sem);
 	mse = busmouse_data[mousedev];
 	if (!mse)
 		/* shouldn't happen, but... */
 		goto end;
 	
-	if (mse->ops &&
-	    mse->ops->open)
+	if (mse->ops && mse->ops->owner)
+		__MOD_INC_USE_COUNT(mse->ops->owner);
+	if (mse->ops && mse->ops->open) {
 		ret = mse->ops->open(inode, file);
+		if (ret && mse->ops->owner)
+			__MOD_DEC_USE_COUNT(mse->ops->owner);
+	}
 
 	if (ret)
 		goto end;
@@ -211,8 +214,6 @@
 	if (mse->active++)
 		goto end;
 
-	MOD_INC_USE_COUNT;
-
 	spin_lock_irq(&mse->lock);
 
 	mse->ready   = 0;
@@ -333,6 +334,7 @@
 
 struct file_operations busmouse_fops=
 {
+	owner:		THIS_MODULE,
 	read:		busmouse_read,
 	write:		busmouse_write,
 	poll:		busmouse_poll,

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