patch-2.4.0-test2 linux/drivers/scsi/sr.c

Next file: linux/drivers/scsi/st.c
Previous file: linux/drivers/scsi/sg.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/drivers/scsi/sr.c linux/drivers/scsi/sr.c
@@ -25,6 +25,9 @@
  *
  *       Modified by Richard Gooch <rgooch@atnf.csiro.au> to support devfs
  *
+ *       Modified by Jens Axboe <axboe@suse.de> - support DVD-RAM
+ *	 transparently and loose the GHOST hack
+ *
  */
 
 #include <linux/module.h>
@@ -297,9 +300,10 @@
 		else
 			printk("sr: can't switch blocksize: in interrupt\n");
 	}
-	if (SCpnt->request.cmd == WRITE) {
+
+	if ((SCpnt->request.cmd == WRITE) && !scsi_CDs[dev].device->writeable)
 		return 0;
-	}
+
 	if (scsi_CDs[dev].device->sector_size == 1024) {
 		if ((block & 1) || (SCpnt->request.nr_sectors & 1)) {
 			printk("sr.c:Bad 1K block number requested (%d %ld)",
@@ -322,9 +326,6 @@
 	}
 	switch (SCpnt->request.cmd) {
 	case WRITE:
-		if (!scsi_CDs[dev].device->writeable) {
-			return 0;
-		}
 		SCpnt->cmnd[0] = WRITE_10;
 		SCpnt->sc_data_direction = SCSI_DATA_WRITE;
 		break;
@@ -587,10 +588,11 @@
 	scsi_CDs[i].readcd_known = 1;
 	scsi_CDs[i].readcd_cdda = buffer[n + 5] & 0x01;
 	/* print some capability bits */
-	printk("sr%i: scsi3-mmc drive: %dx/%dx %s%s%s%s%s\n", i,
+	printk("sr%i: scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n", i,
 	       ((buffer[n + 14] << 8) + buffer[n + 15]) / 176,
 	       scsi_CDs[i].cdi.speed,
 	       buffer[n + 3] & 0x01 ? "writer " : "",	/* CD Writer */
+	       buffer[n + 3] & 0x20 ? "dvd-ram " : "",
 	       buffer[n + 2] & 0x02 ? "cd/rw " : "",	/* can read rewriteable */
 	       buffer[n + 4] & 0x20 ? "xa/form2 " : "",		/* can read xa/from2 */
 	       buffer[n + 5] & 0x01 ? "cdda " : "",	/* can read audio data */
@@ -601,9 +603,12 @@
 	if ((buffer[n + 2] & 0x8) == 0)
 		/* not a DVD drive */
 		scsi_CDs[i].cdi.mask |= CDC_DVD;
-	if ((buffer[n + 3] & 0x20) == 0)
+	if ((buffer[n + 3] & 0x20) == 0) {
 		/* can't write DVD-RAM media */
 		scsi_CDs[i].cdi.mask |= CDC_DVD_RAM;
+	} else {
+		scsi_CDs[i].device->writeable = 1;
+	}
 	if ((buffer[n + 3] & 0x10) == 0)
 		/* can't write DVD-R media */
 		scsi_CDs[i].cdi.mask |= CDC_DVD_R;
@@ -627,7 +632,6 @@
 	/*else    I don't think it can close its tray
 	   scsi_CDs[i].cdi.mask |= CDC_CLOSE_TRAY; */
 
-
 	scsi_free(buffer, 512);
 }
 
@@ -773,9 +777,9 @@
 		sprintf(name, "sr%d", i);
 		strcpy(scsi_CDs[i].cdi.name, name);
                 scsi_CDs[i].cdi.de =
-                    devfs_register (scsi_CDs[i].device->de, "cd", 2,
+                    devfs_register (scsi_CDs[i].device->de, "cd",
                                     DEVFS_FL_DEFAULT, MAJOR_NR, i,
-                                    S_IFBLK | S_IRUGO | S_IWUGO, 0, 0,
+                                    S_IFBLK | S_IRUGO | S_IWUGO,
                                     &cdrom_fops, NULL);
 		register_cdrom(&scsi_CDs[i].cdi);
 	}
@@ -853,7 +857,6 @@
 	}
 	blksize_size[MAJOR_NR] = NULL;
         hardsect_size[MAJOR_NR] = NULL;
-	blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 	blk_size[MAJOR_NR] = NULL;
 	read_ahead[MAJOR_NR] = 0;
 

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