]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: move the writeable field from struct scsi_device to struct scsi_cd
authorChristoph Hellwig <hch@lst.de>
Fri, 18 Jul 2014 14:59:19 +0000 (16:59 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 25 Jul 2014 21:16:41 +0000 (17:16 -0400)
We currently set the field in common code based on the device type,
but then only use it in the cdrom driver which also overrides the
value previously set in the generic code.

Just leave this entirely to the CDROM driver to make everyones life
simpler.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_scan.c
drivers/scsi/sd.c
drivers/scsi/sr.c
drivers/scsi/sr.h
include/scsi/scsi_device.h

index b91cfaf033aaa4fd4f0d15d9b5651caaaed10a7d..a5a0bdeba857d8afbeaf934c0126fe25124e8c15 100644 (file)
@@ -807,30 +807,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
                sdev->removable = (inq_result[1] & 0x80) >> 7;
        }
 
-       switch (sdev->type) {
-       case TYPE_RBC:
-       case TYPE_TAPE:
-       case TYPE_DISK:
-       case TYPE_PRINTER:
-       case TYPE_MOD:
-       case TYPE_PROCESSOR:
-       case TYPE_SCANNER:
-       case TYPE_MEDIUM_CHANGER:
-       case TYPE_ENCLOSURE:
-       case TYPE_COMM:
-       case TYPE_RAID:
-       case TYPE_OSD:
-               sdev->writeable = 1;
-               break;
-       case TYPE_ROM:
-       case TYPE_WORM:
-               sdev->writeable = 0;
-               break;
-       default:
-               sdev_printk(KERN_INFO, sdev, "unknown device type %d\n",
-                           sdev->type);
-       }
-
        if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
                /* RBC and MMC devices can return SCSI-3 compliance and yet
                 * still not support REPORT LUNS, so make them act as
index 3663e38ba4df5ee606e33f5d7a5142f63997d1d3..377a5206017e33885b3d8bef86cb7198c52988bd 100644 (file)
@@ -992,9 +992,6 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
                }
        }
        if (rq_data_dir(rq) == WRITE) {
-               if (!sdp->writeable) {
-                       goto out;
-               }
                SCpnt->cmnd[0] = WRITE_6;
 
                if (blk_integrity_rq(rq))
index cce4771281d93514ff73ad05bef7771cfcc69b2f..7eeb93627beb77f31d00eeb147fc4e44ef6331c5 100644 (file)
@@ -435,7 +435,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
        }
 
        if (rq_data_dir(rq) == WRITE) {
-               if (!cd->device->writeable)
+               if (!cd->writeable)
                        goto out;
                SCpnt->cmnd[0] = WRITE_10;
                cd->cdi.media_written = 1;
@@ -927,7 +927,7 @@ static void get_capabilities(struct scsi_cd *cd)
         */
        if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
                        (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) {
-               cd->device->writeable = 1;
+               cd->writeable = 1;
        }
 
        kfree(buffer);
index 5334e988480d12649b1e9cdc1aa3b7c5b6680efa..1d1f6f416c593daeb888283be777e4a7a3528b7b 100644 (file)
@@ -36,6 +36,7 @@ typedef struct scsi_cd {
        struct scsi_device *device;
        unsigned int vendor;    /* vendor code, see sr_vendor.c         */
        unsigned long ms_offset;        /* for reading multisession-CD's        */
+       unsigned writeable : 1;
        unsigned use:1;         /* is this device still supportable     */
        unsigned xa_flag:1;     /* CD has XA sectors ? */
        unsigned readcd_known:1;        /* drive supports READ_CD (0xbe) */
index 0f853f2c9dc7e2785c9827d019e497688cb01ef0..b895784e2313b0d65ba815416edd8235e16d0ea9 100644 (file)
@@ -127,7 +127,6 @@ struct scsi_device {
                                 * pass settings from slave_alloc to scsi
                                 * core. */
        unsigned int eh_timeout; /* Error handling timeout */
-       unsigned writeable:1;
        unsigned removable:1;
        unsigned changed:1;     /* Data invalid due to media change */
        unsigned busy:1;        /* Used to prevent races */