patch-2.4.0-test2 linux/drivers/cdrom/optcd.c

Next file: linux/drivers/cdrom/sbpcd.c
Previous file: linux/drivers/cdrom/mcd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/drivers/cdrom/optcd.c linux/drivers/cdrom/optcd.c
@@ -1871,6 +1871,8 @@
 {
 	DEBUG((DEBUG_VFS, "starting opt_open"));
 
+	MOD_INC_USE_COUNT;
+
 	if (!open_count && state == S_IDLE) {
 		int status;
 
@@ -1885,12 +1887,12 @@
 		status = drive_status();
 		if (status < 0) {
 			DEBUG((DEBUG_VFS, "drive_status: %02x", -status));
-			return -EIO;
+			goto err_out;
 		}
 		DEBUG((DEBUG_VFS, "status: %02x", status));
 		if ((status & ST_DOOR_OPEN) || (status & ST_DRVERR)) {
 			printk(KERN_INFO "optcd: no disk or door open\n");
-			return -EIO;
+			goto err_out;
 		}
 		status = exec_cmd(COMLOCK);		/* Lock door */
 		if (status < 0) {
@@ -1904,15 +1906,18 @@
 				DEBUG((DEBUG_VFS,
 				       "exec_cmd COMUNLOCK: %02x", -status));
 			}
-			return -EIO;
+			goto err_out;
 		}
 		open_count++;
 	}
-	MOD_INC_USE_COUNT;
 
 	DEBUG((DEBUG_VFS, "exiting opt_open"));
 
 	return 0;
+
+err_out:
+    MOD_DEC_USE_COUNT;
+	return -EIO;
 }
 
 
@@ -2059,8 +2064,8 @@
 		printk(KERN_ERR "optcd: unable to get major %d\n", MAJOR_NR);
 		return -EIO;
 	}
-	devfs_register (NULL, "optcd", 0, DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-			S_IFBLK | S_IRUGO | S_IWUGO, 0, 0, &opt_fops, NULL);
+	devfs_register (NULL, "optcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
+			S_IFBLK | S_IRUGO | S_IWUGO, &opt_fops, NULL);
 	hardsect_size[MAJOR_NR] = &hsecsize;
 	blksize_size[MAJOR_NR] = &blksize;
 	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);

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