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

Next file: linux/drivers/char/buz.c
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-test5/linux/drivers/char/busmouse.c linux/drivers/char/busmouse.c
@@ -172,12 +172,10 @@
 	busmouse_fasync(-1, file, 0);
 
 	if (--mse->active == 0) {
-		if (mse->ops) {
-			if (mse->ops->release)
-				ret = mse->ops->release(inode, file);
-		   	if (mse->ops->owner)
-				__MOD_DEC_USE_COUNT(mse->ops->owner);
-		}
+		if (mse->ops->release)
+			ret = mse->ops->release(inode, file);
+	   	if (mse->ops->owner)
+			__MOD_DEC_USE_COUNT(mse->ops->owner);
 		mse->ready = 0;
 	}
 	unlock_kernel();
@@ -189,7 +187,7 @@
 {
 	struct busmouse_data *mse;
 	unsigned int mousedev;
-	int ret = -ENODEV;
+	int ret;
 
 	mousedev = DEV_TO_MOUSE(inode->i_rdev);
 	if (mousedev >= NR_MICE)
@@ -197,13 +195,15 @@
 
 	down(&mouse_sem);
 	mse = busmouse_data[mousedev];
-	if (!mse)
-		/* shouldn't happen, but... */
+	ret = -ENODEV;
+	if (!mse || !mse->ops)	/* shouldn't happen, but... */
+		goto end;
+
+	if (mse->ops->owner && !try_inc_mod_count(mse->ops->owner))
 		goto end;
-	
-	if (mse->ops && mse->ops->owner)
-		__MOD_INC_USE_COUNT(mse->ops->owner);
-	if (mse->ops && mse->ops->open) {
+
+	ret = 0;
+	if (mse->ops->open) {
 		ret = mse->ops->open(inode, file);
 		if (ret && mse->ops->owner)
 			__MOD_DEC_USE_COUNT(mse->ops->owner);
@@ -222,10 +222,7 @@
 	mse->ready   = 0;
 	mse->dxpos   = 0;
 	mse->dypos   = 0;
-	if (mse->ops)
-		mse->buttons = mse->ops->init_button_state;
-	else
-		mse->buttons = 7;
+	mse->buttons = mse->ops->init_button_state;
 
 	spin_unlock_irq(&mse->lock);
 end:

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