Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+3 -30
-24
drivers/scsi/scsi_scan.c
··· 807 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 810 if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) { 835 811 /* RBC and MMC devices can return SCSI-3 compliance and yet 836 812 * still not support REPORT LUNS, so make them act as
-3
drivers/scsi/sd.c
··· 992 992 } 993 993 } 994 994 if (rq_data_dir(rq) == WRITE) { 995 - if (!sdp->writeable) { 996 - goto out; 997 - } 998 995 SCpnt->cmnd[0] = WRITE_6; 999 996 1000 997 if (blk_integrity_rq(rq))
+2 -2
drivers/scsi/sr.c
··· 435 435 } 436 436 437 437 if (rq_data_dir(rq) == WRITE) { 438 - if (!cd->device->writeable) 438 + if (!cd->writeable) 439 439 goto out; 440 440 SCpnt->cmnd[0] = WRITE_10; 441 441 cd->cdi.media_written = 1; ··· 927 927 */ 928 928 if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) != 929 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 933 kfree(buffer);
+1
drivers/scsi/sr.h
··· 36 36 struct scsi_device *device; 37 37 unsigned int vendor; /* vendor code, see sr_vendor.c */ 38 38 unsigned long ms_offset; /* for reading multisession-CD's */ 39 + unsigned writeable : 1; 39 40 unsigned use:1; /* is this device still supportable */ 40 41 unsigned xa_flag:1; /* CD has XA sectors ? */ 41 42 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
-1
include/scsi/scsi_device.h
··· 127 127 * pass settings from slave_alloc to scsi 128 128 * core. */ 129 129 unsigned int eh_timeout; /* Error handling timeout */ 130 - unsigned writeable:1; 131 130 unsigned removable:1; 132 131 unsigned changed:1; /* Data invalid due to media change */ 133 132 unsigned busy:1; /* Used to prevent races */