patch-2.4.14 linux/drivers/cdrom/mcdx.c

Next file: linux/drivers/cdrom/optcd.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.13/linux/drivers/cdrom/mcdx.c linux/drivers/cdrom/mcdx.c
@@ -219,6 +219,15 @@
 int mcdx_init(void);
 void do_mcdx_request(request_queue_t * q);
 
+struct block_device_operations mcdx_bdops =
+{
+	owner:			THIS_MODULE,
+	open:			cdrom_open,
+	release:		cdrom_release,
+	ioctl:			cdrom_ioctl,
+	check_media_change:	cdrom_media_changed,
+};
+
 
 /*	Indirect exported functions. These functions are exported by their
 	addresses, such as mcdx_open and mcdx_close in the
@@ -640,13 +649,10 @@
 	/* Make the modules looking used ... (thanx bjorn).
 	 * But we shouldn't forget to decrement the module counter
 	 * on error return */
-	MOD_INC_USE_COUNT;
 
 	/* this is only done to test if the drive talks with us */
-	if (-1 == mcdx_getstatus(stuffp, 1)) {
-		MOD_DEC_USE_COUNT;
+	if (-1 == mcdx_getstatus(stuffp, 1))
 		return -EIO;
-	}
 
 	if (stuffp->xxx) {
 
@@ -705,10 +711,8 @@
 		}
 
 		xtrace(OPENCLOSE, "open() init irq generation\n");
-		if (-1 == mcdx_config(stuffp, 1)) {
-			MOD_DEC_USE_COUNT;
+		if (-1 == mcdx_config(stuffp, 1))
 			return -EIO;
-		}
 #if FALLBACK
 		/* Set the read speed */
 		xwarn("AAA %x AAA\n", stuffp->readcmd);
@@ -745,7 +749,7 @@
 								  MODE2 :
 								  MODE1,
 								  1))) {
-					/* MOD_DEC_USE_COUNT, return -EIO; */
+					/* return -EIO; */
 					stuffp->xa = 0;
 					break;
 				}
@@ -765,10 +769,8 @@
 		/* xa disks will be read in raw mode, others not */
 		if (-1 == mcdx_setdrivemode(stuffp,
 					    stuffp->xa ? RAW : COOKED,
-					    1)) {
-			MOD_DEC_USE_COUNT;
+					    1))
 			return -EIO;
-		}
 		if (stuffp->audio) {
 			xinfo("open() audio disk found\n");
 		} else if (stuffp->lastsector >= 0) {
@@ -792,8 +794,6 @@
 	stuffp = mcdx_stuffp[MINOR(cdi->dev)];
 
 	--stuffp->users;
-
-	MOD_DEC_USE_COUNT;
 }
 
 static int mcdx_media_changed(struct cdrom_device_info *cdi, int disc_nr)
@@ -1180,7 +1180,7 @@
 	}
 
 	xtrace(INIT, "init() register blkdev\n");
-	if (devfs_register_blkdev(MAJOR_NR, "mcdx", &cdrom_fops) != 0) {
+	if (devfs_register_blkdev(MAJOR_NR, "mcdx", &mcdx_bdops) != 0) {
 		xwarn("%s=0x%3p,%d: Init failed. Can't get major %d.\n",
 		      MCDX, stuffp->wreg_data, stuffp->irq, MAJOR_NR);
 		kfree(stuffp);
@@ -1240,6 +1240,7 @@
 		blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 		return 2;
 	}
+	devfs_plain_cdrom(&mcdx_info, &mcdx_bdops);
 	printk(msg);
 	return 0;
 }

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