patch-2.4.7 linux/drivers/scsi/sr_ioctl.c
Next file: linux/drivers/scsi/sr_vendor.c
Previous file: linux/drivers/scsi/sr.c
Back to the patch index
Back to the overall index
- Lines: 113
- Date:
Thu Jul 5 11:28:17 2001
- Orig file:
v2.4.6/linux/drivers/scsi/sr_ioctl.c
- Orig date:
Fri Dec 29 14:07:22 2000
diff -u --recursive --new-file v2.4.6/linux/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
@@ -85,6 +85,10 @@
SDev = scsi_CDs[target].device;
SRpnt = scsi_allocate_request(scsi_CDs[target].device);
+ if (!SRpnt) {
+ printk("Unable to allocate SCSI request in sr_do_ioctl");
+ return -ENOMEM;
+ }
SRpnt->sr_data_direction = readwrite;
/* use ISA DMA buffer if necessary */
@@ -191,7 +195,8 @@
u_char sr_cmd[10];
sr_cmd[0] = GPCMD_TEST_UNIT_READY;
- sr_cmd[1] = ((scsi_CDs[minor].device->lun) << 5);
+ sr_cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[minor].device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
return sr_do_ioctl(minor, sr_cmd, NULL, 0, 1, SCSI_DATA_NONE, NULL);
}
@@ -201,7 +206,8 @@
u_char sr_cmd[10];
sr_cmd[0] = GPCMD_START_STOP_UNIT;
- sr_cmd[1] = ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5);
+ sr_cmd[1] = (scsi_CDs[MINOR(cdi->dev)].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
sr_cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ;
@@ -273,7 +279,8 @@
int result;
sr_cmd[0] = GPCMD_READ_SUBCHANNEL;
- sr_cmd[1] = ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5);
+ sr_cmd[1] = (scsi_CDs[MINOR(cdi->dev)].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5) : 0;
sr_cmd[2] = 0x40; /* I do want the subchannel info */
sr_cmd[3] = 0x02; /* Give me medium catalog number info */
sr_cmd[4] = sr_cmd[5] = 0;
@@ -307,7 +314,8 @@
memset(sr_cmd, 0, MAX_COMMAND_SIZE);
sr_cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */
- sr_cmd[1] = (scsi_CDs[MINOR(cdi->dev)].device->lun) << 5;
+ sr_cmd[1] = (scsi_CDs[MINOR(cdi->dev)].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5) : 0;
sr_cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */
sr_cmd[3] = speed & 0xff; /* LSB */
@@ -336,7 +344,8 @@
struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
- sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5);
+ sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[target].device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
sr_cmd[8] = 12; /* LSB of length */
@@ -353,8 +362,9 @@
struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
- sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5) |
- (tocentry->cdte_format == CDROM_MSF ? 0x02 : 0);
+ sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ?
+ ((scsi_CDs[target].device->lun) << 5) : 0;
+ sr_cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
sr_cmd[6] = tocentry->cdte_track;
sr_cmd[8] = 12; /* LSB of length */
@@ -379,7 +389,8 @@
struct cdrom_ti* ti = (struct cdrom_ti*)arg;
sr_cmd[0] = GPCMD_PLAYAUDIO_TI;
- sr_cmd[1] = scsi_CDs[target].device->lun << 5;
+ sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ?
+ (scsi_CDs[target].device->lun << 5) : 0;
sr_cmd[4] = ti->cdti_trk0;
sr_cmd[5] = ti->cdti_ind0;
sr_cmd[7] = ti->cdti_trk1;
@@ -429,7 +440,9 @@
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_CD; /* READ_CD */
- cmd[1] = (scsi_CDs[minor].device->lun << 5) | ((format & 7) << 2);
+ cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ?
+ (scsi_CDs[minor].device->lun << 5) : 0;
+ cmd[1] |= ((format & 7) << 2);
cmd[2] = (unsigned char) (lba >> 24) & 0xff;
cmd[3] = (unsigned char) (lba >> 16) & 0xff;
cmd[4] = (unsigned char) (lba >> 8) & 0xff;
@@ -481,7 +494,8 @@
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_10;
- cmd[1] = (scsi_CDs[minor].device->lun << 5);
+ cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ?
+ (scsi_CDs[minor].device->lun << 5) : 0;
cmd[2] = (unsigned char) (lba >> 24) & 0xff;
cmd[3] = (unsigned char) (lba >> 16) & 0xff;
cmd[4] = (unsigned char) (lba >> 8) & 0xff;
@@ -530,6 +544,8 @@
target = MINOR(cdi->dev);
switch (cmd) {
+ case BLKGETSIZE:
+ return put_user(scsi_CDs[target].capacity >> 1, (long *) arg);
case BLKROSET:
case BLKROGET:
case BLKRASET:
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)