Skip to content

Commit fd2eb90

Browse files
author
Christoph Hellwig
committed
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>
1 parent 7a14c1c commit fd2eb90

5 files changed

Lines changed: 3 additions & 30 deletions

File tree

‎drivers/scsi/scsi_scan.c‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -807,30 +807,6 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
807807
sdev->removable = (inq_result[1] & 0x80) >> 7;
808808
}
809809

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-
834810
if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
835811
/* RBC and MMC devices can return SCSI-3 compliance and yet
836812
* still not support REPORT LUNS, so make them act as

‎drivers/scsi/sd.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,9 +992,6 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
992992
}
993993
}
994994
if (rq_data_dir(rq) == WRITE) {
995-
if (!sdp->writeable) {
996-
goto out;
997-
}
998995
SCpnt->cmnd[0] = WRITE_6;
999996

1000997
if (blk_integrity_rq(rq))

‎drivers/scsi/sr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
435435
}
436436

437437
if (rq_data_dir(rq) == WRITE) {
438-
if (!cd->device->writeable)
438+
if (!cd->writeable)
439439
goto out;
440440
SCpnt->cmnd[0] = WRITE_10;
441441
cd->cdi.media_written = 1;
@@ -927,7 +927,7 @@ static void get_capabilities(struct scsi_cd *cd)
927927
*/
928928
if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
929929
(CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) {
930-
cd->device->writeable = 1;
930+
cd->writeable = 1;
931931
}
932932

933933
kfree(buffer);

‎drivers/scsi/sr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef struct scsi_cd {
3636
struct scsi_device *device;
3737
unsigned int vendor; /* vendor code, see sr_vendor.c */
3838
unsigned long ms_offset; /* for reading multisession-CD's */
39+
unsigned writeable : 1;
3940
unsigned use:1; /* is this device still supportable */
4041
unsigned xa_flag:1; /* CD has XA sectors ? */
4142
unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */

‎include/scsi/scsi_device.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ struct scsi_device {
127127
* pass settings from slave_alloc to scsi
128128
* core. */
129129
unsigned int eh_timeout; /* Error handling timeout */
130-
unsigned writeable:1;
131130
unsigned removable:1;
132131
unsigned changed:1; /* Data invalid due to media change */
133132
unsigned busy:1; /* Used to prevent races */

0 commit comments

Comments
 (0)