aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-07-18 10:59:19 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:16:41 -0400
commitfd2eb9034e48cdca358dc06a833a736e7c6f68dd (patch)
tree18366ad7112141752ca2ab95ec7fd07a9a23f9a3
parent7a14c1c3319608154da8712e4174d56ffb2f7b8d (diff)
scsi: move the writeable field from struct scsi_device to struct scsi_cd
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>
-rw-r--r--drivers/scsi/scsi_scan.c24
-rw-r--r--drivers/scsi/sd.c3
-rw-r--r--drivers/scsi/sr.c4
-rw-r--r--drivers/scsi/sr.h1
-rw-r--r--include/scsi/scsi_device.h1
5 files changed, 3 insertions, 30 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index b91cfaf033aa..a5a0bdeba857 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -807,30 +807,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
807 sdev->removable = (inq_result[1] & 0x80) >> 7; 807 sdev->removable = (inq_result[1] & 0x80) >> 7;
808 } 808 }
809 809
810 switch (sdev->type) {
811 case TYPE_RBC:
812 case TYPE_TAPE:
813 case TYPE_DISK:
814 case TYPE_PRINTER:
815 case TYPE_MOD:
816 case TYPE_PROCESSOR:
817 case TYPE_SCANNER:
818 case TYPE_MEDIUM_CHANGER:
819 case TYPE_ENCLOSURE:
820 case TYPE_COMM:
821 case TYPE_RAID:
822 case TYPE_OSD:
823 sdev->writeable = 1;
824 break;
825 case TYPE_ROM:
826 case TYPE_WORM:
827 sdev->writeable = 0;
828 break;
829 default:
830 sdev_printk(KERN_INFO, sdev, "unknown device type %d\n",
831 sdev->type);
832 }
833
834 if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) { 810 if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
835 /* RBC and MMC devices can return SCSI-3 compliance and yet 811 /* RBC and MMC devices can return SCSI-3 compliance and yet
836 * still not support REPORT LUNS, so make them act as 812 * still not support REPORT LUNS, so make them act as
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3663e38ba4df..377a5206017e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -992,9 +992,6 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
992 } 992 }
993 } 993 }
994 if (rq_data_dir(rq) == WRITE) { 994 if (rq_data_dir(rq) == WRITE) {
995 if (!sdp->writeable) {
996 goto out;
997 }
998 SCpnt->cmnd[0] = WRITE_6; 995 SCpnt->cmnd[0] = WRITE_6;
999 996
1000 if (blk_integrity_rq(rq)) 997 if (blk_integrity_rq(rq))
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index cce4771281d9..7eeb93627beb 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -435,7 +435,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
435 } 435 }
436 436
437 if (rq_data_dir(rq) == WRITE) { 437 if (rq_data_dir(rq) == WRITE) {
438 if (!cd->device->writeable) 438 if (!cd->writeable)
439 goto out; 439 goto out;
440 SCpnt->cmnd[0] = WRITE_10; 440 SCpnt->cmnd[0] = WRITE_10;
441 cd->cdi.media_written = 1; 441 cd->cdi.media_written = 1;
@@ -927,7 +927,7 @@ static void get_capabilities(struct scsi_cd *cd)
927 */ 927 */
928 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) != 928 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
929 (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) { 929 (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) {
930 cd->device->writeable = 1; 930 cd->writeable = 1;
931 } 931 }
932 932
933 kfree(buffer); 933 kfree(buffer);
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
index 5334e988480d..1d1f6f416c59 100644
--- a/drivers/scsi/sr.h
+++ b/drivers/scsi/sr.h
@@ -36,6 +36,7 @@ typedef struct scsi_cd {
36 struct scsi_device *device; 36 struct scsi_device *device;
37 unsigned int vendor; /* vendor code, see sr_vendor.c */ 37 unsigned int vendor; /* vendor code, see sr_vendor.c */
38 unsigned long ms_offset; /* for reading multisession-CD's */ 38 unsigned long ms_offset; /* for reading multisession-CD's */
39 unsigned writeable : 1;
39 unsigned use:1; /* is this device still supportable */ 40 unsigned use:1; /* is this device still supportable */
40 unsigned xa_flag:1; /* CD has XA sectors ? */ 41 unsigned xa_flag:1; /* CD has XA sectors ? */
41 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */ 42 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 0f853f2c9dc7..b895784e2313 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -127,7 +127,6 @@ struct scsi_device {
127 * pass settings from slave_alloc to scsi 127 * pass settings from slave_alloc to scsi
128 * core. */ 128 * core. */
129 unsigned int eh_timeout; /* Error handling timeout */ 129 unsigned int eh_timeout; /* Error handling timeout */
130 unsigned writeable:1;
131 unsigned removable:1; 130 unsigned removable:1;
132 unsigned changed:1; /* Data invalid due to media change */ 131 unsigned changed:1; /* Data invalid due to media change */
133 unsigned busy:1; /* Used to prevent races */ 132 unsigned busy:1; /* Used to prevent races */