Commit dbdb2c5a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] SCSI cdrom cleanup

This is one of the very early steps on cleaning up the SCSI cdrom
driver.  It gets rid of directly accessing the scsi_CDs array in favour
of using the handle we get from the generic cdrom layer.  Also uses
local vars instead of many grouped scsi_CDs accesses in other places.

The gain is to get rid of the global, static array of CDROMS
in the end.
parent a55b9112
This diff is collapsed.
...@@ -53,7 +53,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest); ...@@ -53,7 +53,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest);
int sr_is_xa(int minor); int sr_is_xa(int minor);
/* sr_vendor.c */ /* sr_vendor.c */
void sr_vendor_init(int minor); void sr_vendor_init(Scsi_CD *);
int sr_cd_check(struct cdrom_device_info *); int sr_cd_check(struct cdrom_device_info *);
int sr_set_blocklength(int minor, int blocklength); int sr_set_blocklength(int minor, int blocklength);
......
...@@ -84,7 +84,7 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen ...@@ -84,7 +84,7 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen
char *bounce_buffer; char *bounce_buffer;
SDev = scsi_CDs[target].device; SDev = scsi_CDs[target].device;
SRpnt = scsi_allocate_request(scsi_CDs[target].device); SRpnt = scsi_allocate_request(SDev);
if (!SRpnt) { if (!SRpnt) {
printk("Unable to allocate SCSI request in sr_do_ioctl"); printk("Unable to allocate SCSI request in sr_do_ioctl");
return -ENOMEM; return -ENOMEM;
...@@ -124,7 +124,7 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen ...@@ -124,7 +124,7 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen
if (driver_byte(result) != 0) { if (driver_byte(result) != 0) {
switch (SRpnt->sr_sense_buffer[2] & 0xf) { switch (SRpnt->sr_sense_buffer[2] & 0xf) {
case UNIT_ATTENTION: case UNIT_ATTENTION:
scsi_CDs[target].device->changed = 1; SDev->changed = 1;
if (!quiet) if (!quiet)
printk(KERN_INFO "sr%d: disc change detected.\n", target); printk(KERN_INFO "sr%d: disc change detected.\n", target);
if (retries++ < 10) if (retries++ < 10)
...@@ -192,22 +192,25 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen ...@@ -192,22 +192,25 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen
static int test_unit_ready(int minor) static int test_unit_ready(int minor)
{ {
Scsi_CD *SCp;
u_char sr_cmd[10]; u_char sr_cmd[10];
SCp = &scsi_CDs[minor];
sr_cmd[0] = GPCMD_TEST_UNIT_READY; sr_cmd[0] = GPCMD_TEST_UNIT_READY;
sr_cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[minor].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[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); return sr_do_ioctl(minor, sr_cmd, NULL, 0, 1, SCSI_DATA_NONE, NULL);
} }
int sr_tray_move(struct cdrom_device_info *cdi, int pos) int sr_tray_move(struct cdrom_device_info *cdi, int pos)
{ {
Scsi_CD *SCp = cdi->handle;
u_char sr_cmd[10]; u_char sr_cmd[10];
sr_cmd[0] = GPCMD_START_STOP_UNIT; sr_cmd[0] = GPCMD_START_STOP_UNIT;
sr_cmd[1] = (scsi_CDs[minor(cdi->dev)].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[minor(cdi->dev)].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0; sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
sr_cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ; sr_cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ;
...@@ -216,9 +219,10 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos) ...@@ -216,9 +219,10 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos)
int sr_lock_door(struct cdrom_device_info *cdi, int lock) int sr_lock_door(struct cdrom_device_info *cdi, int lock)
{ {
return scsi_ioctl(scsi_CDs[minor(cdi->dev)].device, Scsi_CD *SCp = cdi->handle;
lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK,
0); return scsi_ioctl(SCp->device, lock ? SCSI_IOCTL_DOORLOCK :
SCSI_IOCTL_DOORUNLOCK, 0);
} }
int sr_drive_status(struct cdrom_device_info *cdi, int slot) int sr_drive_status(struct cdrom_device_info *cdi, int slot)
...@@ -235,6 +239,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot) ...@@ -235,6 +239,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
int sr_disk_status(struct cdrom_device_info *cdi) int sr_disk_status(struct cdrom_device_info *cdi)
{ {
Scsi_CD *SCp = cdi->handle;
struct cdrom_tochdr toc_h; struct cdrom_tochdr toc_h;
struct cdrom_tocentry toc_e; struct cdrom_tocentry toc_e;
int i, rc, have_datatracks = 0; int i, rc, have_datatracks = 0;
...@@ -256,7 +261,7 @@ int sr_disk_status(struct cdrom_device_info *cdi) ...@@ -256,7 +261,7 @@ int sr_disk_status(struct cdrom_device_info *cdi)
if (!have_datatracks) if (!have_datatracks)
return CDS_AUDIO; return CDS_AUDIO;
if (scsi_CDs[minor(cdi->dev)].xa_flag) if (SCp->xa_flag)
return CDS_XA_2_1; return CDS_XA_2_1;
else else
return CDS_DATA_1; return CDS_DATA_1;
...@@ -265,22 +270,24 @@ int sr_disk_status(struct cdrom_device_info *cdi) ...@@ -265,22 +270,24 @@ int sr_disk_status(struct cdrom_device_info *cdi)
int sr_get_last_session(struct cdrom_device_info *cdi, int sr_get_last_session(struct cdrom_device_info *cdi,
struct cdrom_multisession *ms_info) struct cdrom_multisession *ms_info)
{ {
ms_info->addr.lba = scsi_CDs[minor(cdi->dev)].ms_offset; Scsi_CD *SCp = cdi->handle;
ms_info->xa_flag = scsi_CDs[minor(cdi->dev)].xa_flag ||
(scsi_CDs[minor(cdi->dev)].ms_offset > 0); ms_info->addr.lba = SCp->ms_offset;
ms_info->xa_flag = SCp->xa_flag || SCp->ms_offset > 0;
return 0; return 0;
} }
int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
{ {
Scsi_CD *SCp = cdi->handle;
u_char sr_cmd[10]; u_char sr_cmd[10];
char buffer[32]; char buffer[32];
int result; int result;
sr_cmd[0] = GPCMD_READ_SUBCHANNEL; sr_cmd[0] = GPCMD_READ_SUBCHANNEL;
sr_cmd[1] = (scsi_CDs[minor(cdi->dev)].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[minor(cdi->dev)].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[2] = 0x40; /* I do want the subchannel info */ sr_cmd[2] = 0x40; /* I do want the subchannel info */
sr_cmd[3] = 0x02; /* Give me medium catalog number info */ sr_cmd[3] = 0x02; /* Give me medium catalog number info */
sr_cmd[4] = sr_cmd[5] = 0; sr_cmd[4] = sr_cmd[5] = 0;
...@@ -305,6 +312,7 @@ int sr_reset(struct cdrom_device_info *cdi) ...@@ -305,6 +312,7 @@ int sr_reset(struct cdrom_device_info *cdi)
int sr_select_speed(struct cdrom_device_info *cdi, int speed) int sr_select_speed(struct cdrom_device_info *cdi, int speed)
{ {
Scsi_CD *SCp = cdi->handle;
u_char sr_cmd[MAX_COMMAND_SIZE]; u_char sr_cmd[MAX_COMMAND_SIZE];
if (speed == 0) if (speed == 0)
...@@ -314,8 +322,8 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed) ...@@ -314,8 +322,8 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
memset(sr_cmd, 0, MAX_COMMAND_SIZE); memset(sr_cmd, 0, MAX_COMMAND_SIZE);
sr_cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */ sr_cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */
sr_cmd[1] = (scsi_CDs[minor(cdi->dev)].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[minor(cdi->dev)].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */ sr_cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */
sr_cmd[3] = speed & 0xff; /* LSB */ sr_cmd[3] = speed & 0xff; /* LSB */
...@@ -332,6 +340,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed) ...@@ -332,6 +340,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
{ {
Scsi_CD *SCp = cdi->handle;
u_char sr_cmd[10]; u_char sr_cmd[10];
int result, target = minor(cdi->dev); int result, target = minor(cdi->dev);
unsigned char buffer[32]; unsigned char buffer[32];
...@@ -344,8 +353,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -344,8 +353,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg; struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP; sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[target].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0; sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
sr_cmd[8] = 12; /* LSB of length */ sr_cmd[8] = 12; /* LSB of length */
...@@ -362,8 +371,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -362,8 +371,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg; struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP; sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((scsi_CDs[target].device->lun) << 5) : 0; ((SCp->device->lun) << 5) : 0;
sr_cmd[1] |= (tocentry->cdte_format == CDROM_MSF) ? 0x02 : 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[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
sr_cmd[6] = tocentry->cdte_track; sr_cmd[6] = tocentry->cdte_track;
...@@ -389,8 +398,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -389,8 +398,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_ti* ti = (struct cdrom_ti*)arg; struct cdrom_ti* ti = (struct cdrom_ti*)arg;
sr_cmd[0] = GPCMD_PLAYAUDIO_TI; sr_cmd[0] = GPCMD_PLAYAUDIO_TI;
sr_cmd[1] = (scsi_CDs[target].device->scsi_level <= SCSI_2) ? sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[target].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
sr_cmd[4] = ti->cdti_trk0; sr_cmd[4] = ti->cdti_trk0;
sr_cmd[5] = ti->cdti_ind0; sr_cmd[5] = ti->cdti_ind0;
sr_cmd[7] = ti->cdti_trk1; sr_cmd[7] = ti->cdti_trk1;
...@@ -432,6 +441,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -432,6 +441,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize) int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize)
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_CD *SCp = &scsi_CDs[minor];
#ifdef DEBUG #ifdef DEBUG
printk("sr%d: sr_read_cd lba=%d format=%d blksize=%d\n", printk("sr%d: sr_read_cd lba=%d format=%d blksize=%d\n",
...@@ -440,8 +450,8 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize) ...@@ -440,8 +450,8 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize)
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_CD; /* READ_CD */ cmd[0] = GPCMD_READ_CD; /* READ_CD */
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[1] |= ((format & 7) << 2); cmd[1] |= ((format & 7) << 2);
cmd[2] = (unsigned char) (lba >> 24) & 0xff; cmd[2] = (unsigned char) (lba >> 24) & 0xff;
cmd[3] = (unsigned char) (lba >> 16) & 0xff; cmd[3] = (unsigned char) (lba >> 16) & 0xff;
...@@ -472,19 +482,20 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize) ...@@ -472,19 +482,20 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize)
int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */ unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
Scsi_CD *SCp = &scsi_CDs[minor];
int rc; int rc;
/* we try the READ CD command first... */ /* we try the READ CD command first... */
if (scsi_CDs[minor].readcd_known) { if (SCp->readcd_known) {
rc = sr_read_cd(minor, dest, lba, 0, blksize); rc = sr_read_cd(minor, dest, lba, 0, blksize);
if (-EDRIVE_CANT_DO_THIS != rc) if (-EDRIVE_CANT_DO_THIS != rc)
return rc; return rc;
scsi_CDs[minor].readcd_known = 0; SCp->readcd_known = 0;
printk("CDROM does'nt support READ CD (0xbe) command\n"); printk("CDROM does'nt support READ CD (0xbe) command\n");
/* fall & retry the other way */ /* fall & retry the other way */
} }
/* ... if this fails, we switch the blocksize using MODE SELECT */ /* ... if this fails, we switch the blocksize using MODE SELECT */
if (blksize != scsi_CDs[minor].device->sector_size) { if (blksize != SCp->device->sector_size) {
if (0 != (rc = sr_set_blocklength(minor, blksize))) if (0 != (rc = sr_set_blocklength(minor, blksize)))
return rc; return rc;
} }
...@@ -494,8 +505,8 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) ...@@ -494,8 +505,8 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_10; cmd[0] = GPCMD_READ_10;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[2] = (unsigned char) (lba >> 24) & 0xff; cmd[2] = (unsigned char) (lba >> 24) & 0xff;
cmd[3] = (unsigned char) (lba >> 16) & 0xff; cmd[3] = (unsigned char) (lba >> 16) & 0xff;
cmd[4] = (unsigned char) (lba >> 8) & 0xff; cmd[4] = (unsigned char) (lba >> 8) & 0xff;
...@@ -514,6 +525,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) ...@@ -514,6 +525,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
int sr_is_xa(int minor) int sr_is_xa(int minor)
{ {
unsigned char *raw_sector; unsigned char *raw_sector;
Scsi_CD *SCp = &scsi_CDs[minor];
int is_xa; int is_xa;
if (!xa_test) if (!xa_test)
...@@ -522,7 +534,7 @@ int sr_is_xa(int minor) ...@@ -522,7 +534,7 @@ int sr_is_xa(int minor)
raw_sector = (unsigned char *) kmalloc(2048, GFP_DMA | GFP_KERNEL); raw_sector = (unsigned char *) kmalloc(2048, GFP_DMA | GFP_KERNEL);
if (!raw_sector) if (!raw_sector)
return -ENOMEM; return -ENOMEM;
if (0 == sr_read_sector(minor, scsi_CDs[minor].ms_offset + 16, if (0 == sr_read_sector(minor, SCp->ms_offset + 16,
CD_FRAMESIZE_RAW1, raw_sector)) { CD_FRAMESIZE_RAW1, raw_sector)) {
is_xa = (raw_sector[3] == 0x02) ? 1 : 0; is_xa = (raw_sector[3] == 0x02) ? 1 : 0;
} else { } else {
...@@ -539,18 +551,16 @@ int sr_is_xa(int minor) ...@@ -539,18 +551,16 @@ int sr_is_xa(int minor)
int sr_dev_ioctl(struct cdrom_device_info *cdi, int sr_dev_ioctl(struct cdrom_device_info *cdi,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int target; Scsi_CD *SCp = cdi->handle;
target = minor(cdi->dev);
switch (cmd) { switch (cmd) {
case BLKGETSIZE: case BLKGETSIZE:
return put_user(scsi_CDs[target].capacity, (unsigned long *) arg); return put_user(SCp->capacity, (unsigned long *) arg);
case BLKGETSIZE64: case BLKGETSIZE64:
return put_user((u64)scsi_CDs[target].capacity << 9, (u64 *)arg); return put_user((u64)SCp->capacity << 9, (u64 *)arg);
default: default:
return scsi_ioctl(scsi_CDs[target].device, cmd, (void *) arg); return scsi_ioctl(SCp->device, cmd, (void *)arg);
} }
} }
......
...@@ -58,27 +58,25 @@ ...@@ -58,27 +58,25 @@
#define VENDOR_TOSHIBA 3 #define VENDOR_TOSHIBA 3
#define VENDOR_WRITER 4 /* pre-scsi3 writers */ #define VENDOR_WRITER 4 /* pre-scsi3 writers */
#define VENDOR_ID (scsi_CDs[minor].vendor) void sr_vendor_init(Scsi_CD *SCp)
void sr_vendor_init(int minor)
{ {
#ifndef CONFIG_BLK_DEV_SR_VENDOR #ifndef CONFIG_BLK_DEV_SR_VENDOR
VENDOR_ID = VENDOR_SCSI3; SCp->vendor = VENDOR_SCSI3;
#else #else
char *vendor = scsi_CDs[minor].device->vendor; char *vendor = SCp->device->vendor;
char *model = scsi_CDs[minor].device->model; char *model = SCp->device->model;
/* default */ /* default */
VENDOR_ID = VENDOR_SCSI3; SCp->vendor = VENDOR_SCSI3;
if (scsi_CDs[minor].readcd_known) if (SCp->readcd_known)
/* this is true for scsi3/mmc drives - no more checks */ /* this is true for scsi3/mmc drives - no more checks */
return; return;
if (scsi_CDs[minor].device->type == TYPE_WORM) { if (SCp->device->type == TYPE_WORM) {
VENDOR_ID = VENDOR_WRITER; SCp->vendor = VENDOR_WRITER;
} else if (!strncmp(vendor, "NEC", 3)) { } else if (!strncmp(vendor, "NEC", 3)) {
VENDOR_ID = VENDOR_NEC; SCp->vendor = VENDOR_NEC;
if (!strncmp(model, "CD-ROM DRIVE:25", 15) || if (!strncmp(model, "CD-ROM DRIVE:25", 15) ||
!strncmp(model, "CD-ROM DRIVE:36", 15) || !strncmp(model, "CD-ROM DRIVE:36", 15) ||
!strncmp(model, "CD-ROM DRIVE:83", 15) || !strncmp(model, "CD-ROM DRIVE:83", 15) ||
...@@ -90,10 +88,10 @@ void sr_vendor_init(int minor) ...@@ -90,10 +88,10 @@ void sr_vendor_init(int minor)
#endif #endif
) )
/* these can't handle multisession, may hang */ /* these can't handle multisession, may hang */
scsi_CDs[minor].cdi.mask |= CDC_MULTI_SESSION; SCp->cdi.mask |= CDC_MULTI_SESSION;
} else if (!strncmp(vendor, "TOSHIBA", 7)) { } else if (!strncmp(vendor, "TOSHIBA", 7)) {
VENDOR_ID = VENDOR_TOSHIBA; SCp->vendor = VENDOR_TOSHIBA;
} }
#endif #endif
...@@ -108,10 +106,11 @@ int sr_set_blocklength(int minor, int blocklength) ...@@ -108,10 +106,11 @@ int sr_set_blocklength(int minor, int blocklength)
unsigned char *buffer; /* the buffer for the ioctl */ unsigned char *buffer; /* the buffer for the ioctl */
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */ unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
struct ccs_modesel_head *modesel; struct ccs_modesel_head *modesel;
Scsi_CD *SCp = &scsi_CDs[minor];
int rc, density = 0; int rc, density = 0;
#ifdef CONFIG_BLK_DEV_SR_VENDOR #ifdef CONFIG_BLK_DEV_SR_VENDOR
if (VENDOR_ID == VENDOR_TOSHIBA) if (SCp->vendor == VENDOR_TOSHIBA)
density = (blocklength > 2048) ? 0x81 : 0x83; density = (blocklength > 2048) ? 0x81 : 0x83;
#endif #endif
...@@ -124,8 +123,8 @@ int sr_set_blocklength(int minor, int blocklength) ...@@ -124,8 +123,8 @@ int sr_set_blocklength(int minor, int blocklength)
#endif #endif
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = MODE_SELECT; cmd[0] = MODE_SELECT;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[1] |= (1 << 4); cmd[1] |= (1 << 4);
cmd[4] = 12; cmd[4] = 12;
modesel = (struct ccs_modesel_head *) buffer; modesel = (struct ccs_modesel_head *) buffer;
...@@ -135,7 +134,7 @@ int sr_set_blocklength(int minor, int blocklength) ...@@ -135,7 +134,7 @@ int sr_set_blocklength(int minor, int blocklength)
modesel->block_length_med = (blocklength >> 8) & 0xff; modesel->block_length_med = (blocklength >> 8) & 0xff;
modesel->block_length_lo = blocklength & 0xff; modesel->block_length_lo = blocklength & 0xff;
if (0 == (rc = sr_do_ioctl(minor, cmd, buffer, sizeof(*modesel), 0, SCSI_DATA_WRITE, NULL))) { if (0 == (rc = sr_do_ioctl(minor, cmd, buffer, sizeof(*modesel), 0, SCSI_DATA_WRITE, NULL))) {
scsi_CDs[minor].device->sector_size = blocklength; SCp->device->sector_size = blocklength;
} }
#ifdef DEBUG #ifdef DEBUG
else else
...@@ -153,13 +152,14 @@ int sr_set_blocklength(int minor, int blocklength) ...@@ -153,13 +152,14 @@ int sr_set_blocklength(int minor, int blocklength)
int sr_cd_check(struct cdrom_device_info *cdi) int sr_cd_check(struct cdrom_device_info *cdi)
{ {
Scsi_CD *SCp = cdi->handle;
unsigned long sector; unsigned long sector;
unsigned char *buffer; /* the buffer for the ioctl */ unsigned char *buffer; /* the buffer for the ioctl */
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */ unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
int rc, no_multi, minor; int rc, no_multi, minor;
minor = minor(cdi->dev); minor = minor(cdi->dev);
if (scsi_CDs[minor].cdi.mask & CDC_MULTI_SESSION) if (SCp->cdi.mask & CDC_MULTI_SESSION)
return 0; return 0;
buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA);
...@@ -170,13 +170,13 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -170,13 +170,13 @@ int sr_cd_check(struct cdrom_device_info *cdi)
no_multi = 0; /* flag: the drive can't handle multisession */ no_multi = 0; /* flag: the drive can't handle multisession */
rc = 0; rc = 0;
switch (VENDOR_ID) { switch (SCp->vendor) {
case VENDOR_SCSI3: case VENDOR_SCSI3:
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = READ_TOC; cmd[0] = READ_TOC;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[8] = 12; cmd[8] = 12;
cmd[9] = 0x40; cmd[9] = 0x40;
rc = sr_do_ioctl(minor, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(minor, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL);
...@@ -201,8 +201,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -201,8 +201,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
unsigned long min, sec, frame; unsigned long min, sec, frame;
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = 0xde; cmd[0] = 0xde;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[1] |= 0x03; cmd[1] |= 0x03;
cmd[2] = 0xb0; cmd[2] = 0xb0;
rc = sr_do_ioctl(minor, cmd, buffer, 0x16, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(minor, cmd, buffer, 0x16, 1, SCSI_DATA_READ, NULL);
...@@ -228,8 +228,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -228,8 +228,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
* where starts the last session ?) */ * where starts the last session ?) */
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = 0xc7; cmd[0] = 0xc7;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[1] |= 0x03; cmd[1] |= 0x03;
rc = sr_do_ioctl(minor, cmd, buffer, 4, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(minor, cmd, buffer, 4, 1, SCSI_DATA_READ, NULL);
if (rc == -EINVAL) { if (rc == -EINVAL) {
...@@ -253,8 +253,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -253,8 +253,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
case VENDOR_WRITER: case VENDOR_WRITER:
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = READ_TOC; cmd[0] = READ_TOC;
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[8] = 0x04; cmd[8] = 0x04;
cmd[9] = 0x40; cmd[9] = 0x40;
rc = sr_do_ioctl(minor, cmd, buffer, 0x04, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(minor, cmd, buffer, 0x04, 1, SCSI_DATA_READ, NULL);
...@@ -267,8 +267,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -267,8 +267,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
break; break;
} }
cmd[0] = READ_TOC; /* Read TOC */ cmd[0] = READ_TOC; /* Read TOC */
cmd[1] = (scsi_CDs[minor].device->scsi_level <= SCSI_2) ? cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(scsi_CDs[minor].device->lun << 5) : 0; (SCp->device->lun << 5) : 0;
cmd[6] = rc & 0x7f; /* number of last session */ cmd[6] = rc & 0x7f; /* number of last session */
cmd[8] = 0x0c; cmd[8] = 0x0c;
cmd[9] = 0x40; cmd[9] = 0x40;
...@@ -285,17 +285,17 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -285,17 +285,17 @@ int sr_cd_check(struct cdrom_device_info *cdi)
/* should not happen */ /* should not happen */
printk(KERN_WARNING printk(KERN_WARNING
"sr%d: unknown vendor code (%i), not initialized ?\n", "sr%d: unknown vendor code (%i), not initialized ?\n",
minor, VENDOR_ID); minor, SCp->vendor);
sector = 0; sector = 0;
no_multi = 1; no_multi = 1;
break; break;
} }
scsi_CDs[minor].ms_offset = sector; SCp->ms_offset = sector;
scsi_CDs[minor].xa_flag = 0; SCp->xa_flag = 0;
if (CDS_AUDIO != sr_disk_status(cdi) && 1 == sr_is_xa(minor)) if (CDS_AUDIO != sr_disk_status(cdi) && 1 == sr_is_xa(minor))
scsi_CDs[minor].xa_flag = 1; SCp->xa_flag = 1;
if (2048 != scsi_CDs[minor].device->sector_size) { if (2048 != SCp->device->sector_size) {
sr_set_blocklength(minor, 2048); sr_set_blocklength(minor, 2048);
} }
if (no_multi) if (no_multi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment