Commit 6f14c533 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (12/25) sr.c passes pointers instead of minors now

	 killed passing minors around; we always pass a pointer to structure;
scsi_CDs made static.  That killed uses of cdi->dev in sr.c and friends.
parent c7633c22
...@@ -87,12 +87,12 @@ static struct Scsi_Device_Template sr_template = ...@@ -87,12 +87,12 @@ static struct Scsi_Device_Template sr_template =
init_command:sr_init_command init_command:sr_init_command
}; };
Scsi_CD *scsi_CDs; static Scsi_CD *scsi_CDs;
static int *sr_sizes; static int *sr_sizes;
static int sr_open(struct cdrom_device_info *, int); static int sr_open(struct cdrom_device_info *, int);
void get_sectorsize(int); static void get_sectorsize(Scsi_CD *);
void get_capabilities(int); static void get_capabilities(Scsi_CD *);
static int sr_media_change(struct cdrom_device_info *, int); static int sr_media_change(struct cdrom_device_info *, int);
static int sr_packet(struct cdrom_device_info *, struct cdrom_generic_command *); static int sr_packet(struct cdrom_device_info *, struct cdrom_generic_command *);
...@@ -102,7 +102,7 @@ static void sr_release(struct cdrom_device_info *cdi) ...@@ -102,7 +102,7 @@ static void sr_release(struct cdrom_device_info *cdi)
Scsi_CD *cd = cdi->handle; Scsi_CD *cd = cdi->handle;
if (cd->device->sector_size > 2048) if (cd->device->sector_size > 2048)
sr_set_blocklength(minor(cdi->dev), 2048); sr_set_blocklength(cd, 2048);
cd->device->access_count--; cd->device->access_count--;
if (cd->device->host->hostt->module) if (cd->device->host->hostt->module)
__MOD_DEC_USE_COUNT(cd->device->host->hostt->module); __MOD_DEC_USE_COUNT(cd->device->host->hostt->module);
...@@ -298,7 +298,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt) ...@@ -298,7 +298,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
s_size = cd->device->sector_size; s_size = cd->device->sector_size;
if (s_size > 2048) { if (s_size > 2048) {
if (!in_interrupt()) if (!in_interrupt())
sr_set_blocklength(DEVICE_NR(CURRENT->rq_dev), 2048); sr_set_blocklength(cd, 2048);
else else
printk("sr: can't switch blocksize: in interrupt\n"); printk("sr: can't switch blocksize: in interrupt\n");
} }
...@@ -402,9 +402,8 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose) ...@@ -402,9 +402,8 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
{ {
Scsi_CD *cd = cdi->handle; Scsi_CD *cd = cdi->handle;
if (minor(cdi->dev) >= sr_template.dev_max || !cd->device) { if (!cd->device)
return -ENXIO; /* No such device */ return -ENXIO; /* No such device */
}
/* /*
* If the device is in error recovery, wait until it is done. * If the device is in error recovery, wait until it is done.
* If the device is offline, then disallow any access to it. * If the device is offline, then disallow any access to it.
...@@ -424,7 +423,7 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose) ...@@ -424,7 +423,7 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
*/ */
if (cd->needs_sector_size) if (cd->needs_sector_size)
get_sectorsize(minor(cdi->dev)); get_sectorsize(cd);
return 0; return 0;
} }
...@@ -470,17 +469,16 @@ static int sr_attach(Scsi_Device * SDp) ...@@ -470,17 +469,16 @@ static int sr_attach(Scsi_Device * SDp)
} }
void get_sectorsize(int i) static void get_sectorsize(Scsi_CD *cd)
{ {
unsigned char cmd[10]; unsigned char cmd[10];
unsigned char *buffer; unsigned char *buffer;
int the_result, retries = 3; int the_result, retries = 3;
int sector_size; int sector_size;
Scsi_Request *SRpnt = NULL; Scsi_Request *SRpnt = NULL;
Scsi_CD *cd;
request_queue_t *queue; request_queue_t *queue;
int unit = cd - scsi_CDs; /* gack... we still need it for corresponding
cd = &scsi_CDs[i]; sr_sizes[] element access */
buffer = kmalloc(512, GFP_DMA); buffer = kmalloc(512, GFP_DMA);
if (!buffer) if (!buffer)
...@@ -560,7 +558,7 @@ void get_sectorsize(int i) ...@@ -560,7 +558,7 @@ void get_sectorsize(int i)
* what the device is capable of. * what the device is capable of.
*/ */
cd->needs_sector_size = 0; cd->needs_sector_size = 0;
sr_sizes[i] = cd->capacity >> (BLOCK_SIZE_BITS - 9); sr_sizes[unit] = cd->capacity >> (BLOCK_SIZE_BITS - 9);
} }
queue = &cd->device->request_queue; queue = &cd->device->request_queue;
...@@ -578,9 +576,8 @@ void get_sectorsize(int i) ...@@ -578,9 +576,8 @@ void get_sectorsize(int i)
goto out; goto out;
} }
void get_capabilities(int i) void get_capabilities(Scsi_CD *cd)
{ {
Scsi_CD *cd;
unsigned char cmd[6]; unsigned char cmd[6];
unsigned char *buffer; unsigned char *buffer;
int rc, n; int rc, n;
...@@ -597,7 +594,6 @@ void get_capabilities(int i) ...@@ -597,7 +594,6 @@ void get_capabilities(int i)
"" ""
}; };
cd = &scsi_CDs[i];
buffer = kmalloc(512, GFP_DMA); buffer = kmalloc(512, GFP_DMA);
if (!buffer) if (!buffer)
{ {
...@@ -610,7 +606,7 @@ void get_capabilities(int i) ...@@ -610,7 +606,7 @@ void get_capabilities(int i)
cmd[2] = 0x2a; cmd[2] = 0x2a;
cmd[4] = 128; cmd[4] = 128;
cmd[3] = cmd[5] = 0; cmd[3] = cmd[5] = 0;
rc = sr_do_ioctl(i, cmd, buffer, 128, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(cd, cmd, buffer, 128, 1, SCSI_DATA_READ, NULL);
if (rc) { if (rc) {
/* failed, drive doesn't have capabilities mode page */ /* failed, drive doesn't have capabilities mode page */
...@@ -687,7 +683,7 @@ static int sr_packet(struct cdrom_device_info *cdi, struct cdrom_generic_command ...@@ -687,7 +683,7 @@ static int sr_packet(struct cdrom_device_info *cdi, struct cdrom_generic_command
if (device->scsi_level <= SCSI_2) if (device->scsi_level <= SCSI_2)
cgc->cmd[1] |= device->lun << 5; cgc->cmd[1] |= device->lun << 5;
cgc->stat = sr_do_ioctl(minor(cdi->dev), cgc->cmd, cgc->buffer, cgc->buflen, cgc->quiet, cgc->data_direction, cgc->sense); cgc->stat = sr_do_ioctl(cdi->handle, cgc->cmd, cgc->buffer, cgc->buflen, cgc->quiet, cgc->data_direction, cgc->sense);
return cgc->stat; return cgc->stat;
} }
...@@ -769,7 +765,7 @@ void sr_finish() ...@@ -769,7 +765,7 @@ void sr_finish()
cd->device->changed = 1; /* force recheck CD type */ cd->device->changed = 1; /* force recheck CD type */
#if 0 #if 0
/* seems better to leave this for later */ /* seems better to leave this for later */
get_sectorsize(i); get_sectorsize(cd);
printk("Scd sectorsize = %d bytes.\n", cd->sector_size); printk("Scd sectorsize = %d bytes.\n", cd->sector_size);
#endif #endif
cd->use = 1; cd->use = 1;
...@@ -789,7 +785,7 @@ void sr_finish() ...@@ -789,7 +785,7 @@ void sr_finish()
* FIXME: someone needs to handle a get_capabilities * FIXME: someone needs to handle a get_capabilities
* failure properly ?? * failure properly ??
*/ */
get_capabilities(i); get_capabilities(cd);
sr_vendor_init(cd); sr_vendor_init(cd);
sprintf(cd->cdi.cdrom_driverfs_dev.bus_id, "%s:cd", sprintf(cd->cdi.cdrom_driverfs_dev.bus_id, "%s:cd",
......
...@@ -32,9 +32,7 @@ typedef struct { ...@@ -32,9 +32,7 @@ typedef struct {
struct cdrom_device_info cdi; struct cdrom_device_info cdi;
} Scsi_CD; } Scsi_CD;
extern Scsi_CD *scsi_CDs; int sr_do_ioctl(Scsi_CD *, unsigned char *, void *, unsigned, int, int, struct request_sense *);
int sr_do_ioctl(int, unsigned char *, void *, unsigned, int, int, struct request_sense *);
int sr_lock_door(struct cdrom_device_info *, int); int sr_lock_door(struct cdrom_device_info *, int);
int sr_tray_move(struct cdrom_device_info *, int); int sr_tray_move(struct cdrom_device_info *, int);
...@@ -47,12 +45,11 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed); ...@@ -47,12 +45,11 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed);
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *); int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long); int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long);
int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest); int sr_is_xa(Scsi_CD *);
int sr_is_xa(int minor);
/* sr_vendor.c */ /* sr_vendor.c */
void sr_vendor_init(Scsi_CD *); 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(Scsi_CD *, int blocklength);
#endif #endif
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
* It is off by default and can be turned on with this module parameter */ * It is off by default and can be turned on with this module parameter */
static int xa_test = 0; static int xa_test = 0;
extern void get_sectorsize(int);
#define IOCTL_RETRIES 3 #define IOCTL_RETRIES 3
/* The CDROM is fairly slow, so we need a little extra time */ /* The CDROM is fairly slow, so we need a little extra time */
/* In fact, it is very slow if it has to spin up first */ /* In fact, it is very slow if it has to spin up first */
...@@ -69,16 +67,15 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti ...@@ -69,16 +67,15 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
sr_cmd[6] = trk1_te.cdte_addr.msf.minute; sr_cmd[6] = trk1_te.cdte_addr.msf.minute;
sr_cmd[7] = trk1_te.cdte_addr.msf.second; sr_cmd[7] = trk1_te.cdte_addr.msf.second;
sr_cmd[8] = trk1_te.cdte_addr.msf.frame; sr_cmd[8] = trk1_te.cdte_addr.msf.frame;
return sr_do_ioctl(minor(cdi->dev), sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL); return sr_do_ioctl(cdi->handle, sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL);
} }
/* We do our own retries because we want to know what the specific /* We do our own retries because we want to know what the specific
error code is. Normally the UNIT_ATTENTION code will automatically error code is. Normally the UNIT_ATTENTION code will automatically
clear after one error */ clear after one error */
int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflength, int quiet, int readwrite, struct request_sense *sense) int sr_do_ioctl(Scsi_CD *cd, unsigned char *sr_cmd, void *buffer, unsigned buflength, int quiet, int readwrite, struct request_sense *sense)
{ {
Scsi_CD *cd = &scsi_CDs[target];
Scsi_Request *SRpnt; Scsi_Request *SRpnt;
Scsi_Device *SDev; Scsi_Device *SDev;
struct request *req; struct request *req;
...@@ -192,17 +189,15 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen ...@@ -192,17 +189,15 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* interface to cdrom.c */ /* interface to cdrom.c */
static int test_unit_ready(int minor) static int test_unit_ready(Scsi_CD *cd)
{ {
Scsi_CD *cd;
u_char sr_cmd[10]; u_char sr_cmd[10];
cd = &scsi_CDs[minor];
sr_cmd[0] = GPCMD_TEST_UNIT_READY; sr_cmd[0] = GPCMD_TEST_UNIT_READY;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ? sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun) << 5) : 0; ((cd->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(cd, 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)
...@@ -216,7 +211,7 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos) ...@@ -216,7 +211,7 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos)
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 */ ;
return sr_do_ioctl(minor(cdi->dev), sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL); return sr_do_ioctl(cd, sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL);
} }
int sr_lock_door(struct cdrom_device_info *cdi, int lock) int sr_lock_door(struct cdrom_device_info *cdi, int lock)
...@@ -233,7 +228,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot) ...@@ -233,7 +228,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
/* we have no changer support */ /* we have no changer support */
return -EINVAL; return -EINVAL;
} }
if (0 == test_unit_ready(minor(cdi->dev))) if (0 == test_unit_ready(cdi->handle))
return CDS_DISC_OK; return CDS_DISC_OK;
return CDS_TRAY_OPEN; return CDS_TRAY_OPEN;
...@@ -298,7 +293,7 @@ int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) ...@@ -298,7 +293,7 @@ int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
sr_cmd[8] = 24; sr_cmd[8] = 24;
sr_cmd[9] = 0; sr_cmd[9] = 0;
result = sr_do_ioctl(minor(cdi->dev), sr_cmd, buffer, 24, 0, SCSI_DATA_READ, NULL); result = sr_do_ioctl(cd, sr_cmd, buffer, 24, 0, SCSI_DATA_READ, NULL);
memcpy(mcn->medium_catalog_number, buffer + 9, 13); memcpy(mcn->medium_catalog_number, buffer + 9, 13);
mcn->medium_catalog_number[13] = 0; mcn->medium_catalog_number[13] = 0;
...@@ -329,7 +324,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed) ...@@ -329,7 +324,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
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 */
if (sr_do_ioctl(minor(cdi->dev), sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL)) if (sr_do_ioctl(cd, sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL))
return -EIO; return -EIO;
return 0; return 0;
} }
...@@ -344,7 +339,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -344,7 +339,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
{ {
Scsi_CD *cd = cdi->handle; Scsi_CD *cd = cdi->handle;
u_char sr_cmd[10]; u_char sr_cmd[10];
int result, target = minor(cdi->dev); int result;
unsigned char buffer[32]; unsigned char buffer[32];
memset(sr_cmd, 0, sizeof(sr_cmd)); memset(sr_cmd, 0, sizeof(sr_cmd));
...@@ -360,7 +355,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -360,7 +355,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
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 */
result = sr_do_ioctl(target, sr_cmd, buffer, 12, 1, SCSI_DATA_READ, NULL); result = sr_do_ioctl(cd, sr_cmd, buffer, 12, 1, SCSI_DATA_READ, NULL);
tochdr->cdth_trk0 = buffer[2]; tochdr->cdth_trk0 = buffer[2];
tochdr->cdth_trk1 = buffer[3]; tochdr->cdth_trk1 = buffer[3];
...@@ -380,7 +375,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -380,7 +375,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
sr_cmd[6] = tocentry->cdte_track; sr_cmd[6] = tocentry->cdte_track;
sr_cmd[8] = 12; /* LSB of length */ sr_cmd[8] = 12; /* LSB of length */
result = sr_do_ioctl(target, sr_cmd, buffer, 12, 0, SCSI_DATA_READ, NULL); result = sr_do_ioctl(cd, sr_cmd, buffer, 12, 0, SCSI_DATA_READ, NULL);
tocentry->cdte_ctrl = buffer[5] & 0xf; tocentry->cdte_ctrl = buffer[5] & 0xf;
tocentry->cdte_adr = buffer[5] >> 4; tocentry->cdte_adr = buffer[5] >> 4;
...@@ -407,7 +402,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -407,7 +402,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
sr_cmd[7] = ti->cdti_trk1; sr_cmd[7] = ti->cdti_trk1;
sr_cmd[8] = ti->cdti_ind1; sr_cmd[8] = ti->cdti_ind1;
result = sr_do_ioctl(target, sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL); result = sr_do_ioctl(cd, sr_cmd, NULL, 0, 0, SCSI_DATA_NONE, NULL);
if (result == -EDRIVE_CANT_DO_THIS) if (result == -EDRIVE_CANT_DO_THIS)
result = sr_fake_playtrkind(cdi, ti); result = sr_fake_playtrkind(cdi, ti);
...@@ -440,10 +435,9 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -440,10 +435,9 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
* blksize: 2048 | 2336 | 2340 | 2352 * blksize: 2048 | 2336 | 2340 | 2352
*/ */
int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize) static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int blksize)
{ {
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_CD *cd = &scsi_CDs[minor];
#ifdef DEBUG #ifdef DEBUG
printk("%s: sr_read_cd lba=%d format=%d blksize=%d\n", printk("%s: sr_read_cd lba=%d format=%d blksize=%d\n",
...@@ -474,22 +468,21 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize) ...@@ -474,22 +468,21 @@ int sr_read_cd(int minor, unsigned char *dest, int lba, int format, int blksize)
cmd[9] = 0x10; cmd[9] = 0x10;
break; break;
} }
return sr_do_ioctl(minor, cmd, dest, blksize, 0, SCSI_DATA_READ, NULL); return sr_do_ioctl(cd, cmd, dest, blksize, 0, SCSI_DATA_READ, NULL);
} }
/* /*
* read sectors with blocksizes other than 2048 * read sectors with blocksizes other than 2048
*/ */
int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) static int sr_read_sector(Scsi_CD *cd, 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 *cd = &scsi_CDs[minor];
int rc; int rc;
/* we try the READ CD command first... */ /* we try the READ CD command first... */
if (cd->readcd_known) { if (cd->readcd_known) {
rc = sr_read_cd(minor, dest, lba, 0, blksize); rc = sr_read_cd(cd, dest, lba, 0, blksize);
if (-EDRIVE_CANT_DO_THIS != rc) if (-EDRIVE_CANT_DO_THIS != rc)
return rc; return rc;
cd->readcd_known = 0; cd->readcd_known = 0;
...@@ -498,7 +491,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) ...@@ -498,7 +491,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
} }
/* ... if this fails, we switch the blocksize using MODE SELECT */ /* ... if this fails, we switch the blocksize using MODE SELECT */
if (blksize != cd->device->sector_size) { if (blksize != cd->device->sector_size) {
if (0 != (rc = sr_set_blocklength(minor, blksize))) if (0 != (rc = sr_set_blocklength(cd, blksize)))
return rc; return rc;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -514,7 +507,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) ...@@ -514,7 +507,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
cmd[4] = (unsigned char) (lba >> 8) & 0xff; cmd[4] = (unsigned char) (lba >> 8) & 0xff;
cmd[5] = (unsigned char) lba & 0xff; cmd[5] = (unsigned char) lba & 0xff;
cmd[8] = 1; cmd[8] = 1;
rc = sr_do_ioctl(minor, cmd, dest, blksize, 0, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(cd, cmd, dest, blksize, 0, SCSI_DATA_READ, NULL);
return rc; return rc;
} }
...@@ -524,10 +517,9 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest) ...@@ -524,10 +517,9 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
* ret: 1 == mode2 (XA), 0 == mode1, <0 == error * ret: 1 == mode2 (XA), 0 == mode1, <0 == error
*/ */
int sr_is_xa(int minor) int sr_is_xa(Scsi_CD *cd)
{ {
unsigned char *raw_sector; unsigned char *raw_sector;
Scsi_CD *cd = &scsi_CDs[minor];
int is_xa; int is_xa;
if (!xa_test) if (!xa_test)
...@@ -536,7 +528,7 @@ int sr_is_xa(int minor) ...@@ -536,7 +528,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, cd->ms_offset + 16, if (0 == sr_read_sector(cd, cd->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 {
......
...@@ -101,12 +101,11 @@ void sr_vendor_init(Scsi_CD *cd) ...@@ -101,12 +101,11 @@ void sr_vendor_init(Scsi_CD *cd)
/* small handy function for switching block length using MODE SELECT, /* small handy function for switching block length using MODE SELECT,
* used by sr_read_sector() */ * used by sr_read_sector() */
int sr_set_blocklength(int minor, int blocklength) int sr_set_blocklength(Scsi_CD *cd, 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 *cd = &scsi_CDs[minor];
int rc, density = 0; int rc, density = 0;
#ifdef CONFIG_BLK_DEV_SR_VENDOR #ifdef CONFIG_BLK_DEV_SR_VENDOR
...@@ -133,7 +132,7 @@ int sr_set_blocklength(int minor, int blocklength) ...@@ -133,7 +132,7 @@ int sr_set_blocklength(int minor, int blocklength)
modesel->density = density; modesel->density = density;
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(cd, cmd, buffer, sizeof(*modesel), 0, SCSI_DATA_WRITE, NULL))) {
cd->device->sector_size = blocklength; cd->device->sector_size = blocklength;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -156,9 +155,8 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -156,9 +155,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
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(cdi->dev);
if (cd->cdi.mask & CDC_MULTI_SESSION) if (cd->cdi.mask & CDC_MULTI_SESSION)
return 0; return 0;
...@@ -179,7 +177,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -179,7 +177,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
(cd->device->lun << 5) : 0; (cd->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(cd, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL);
if (rc != 0) if (rc != 0)
break; break;
if ((buffer[0] << 8) + buffer[1] < 0x0a) { if ((buffer[0] << 8) + buffer[1] < 0x0a) {
...@@ -205,12 +203,13 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -205,12 +203,13 @@ int sr_cd_check(struct cdrom_device_info *cdi)
(cd->device->lun << 5) : 0; (cd->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(cd, cmd, buffer, 0x16, 1, SCSI_DATA_READ, NULL);
if (rc != 0) if (rc != 0)
break; break;
if (buffer[14] != 0 && buffer[14] != 0xb0) { if (buffer[14] != 0 && buffer[14] != 0xb0) {
printk(KERN_INFO "%s: Hmm, seems the cdrom " printk(KERN_INFO "%s: Hmm, seems the cdrom "
"doesn't support multisession CD's\n", cd->cdi.name); "doesn't support multisession CD's\n",
cd->cdi.name);
no_multi = 1; no_multi = 1;
break; break;
} }
...@@ -231,10 +230,11 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -231,10 +230,11 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cmd[1] = (cd->device->scsi_level <= SCSI_2) ? cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0; (cd->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(cd, cmd, buffer, 4, 1, SCSI_DATA_READ, NULL);
if (rc == -EINVAL) { if (rc == -EINVAL) {
printk(KERN_INFO "%s: Hmm, seems the drive " printk(KERN_INFO "%s: Hmm, seems the drive "
"doesn't support multisession CD's\n", cd->cdi.name); "doesn't support multisession CD's\n",
cd->cdi.name);
no_multi = 1; no_multi = 1;
break; break;
} }
...@@ -246,7 +246,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -246,7 +246,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame;
if (sector) if (sector)
sector -= CD_MSF_OFFSET; sector -= CD_MSF_OFFSET;
sr_set_blocklength(minor, 2048); sr_set_blocklength(cd, 2048);
break; break;
} }
...@@ -257,7 +257,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -257,7 +257,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
(cd->device->lun << 5) : 0; (cd->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(cd, cmd, buffer, 0x04, 1, SCSI_DATA_READ, NULL);
if (rc != 0) { if (rc != 0) {
break; break;
} }
...@@ -272,7 +272,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -272,7 +272,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
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;
rc = sr_do_ioctl(minor, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL); rc = sr_do_ioctl(cd, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL);
if (rc != 0) { if (rc != 0) {
break; break;
} }
...@@ -292,11 +292,11 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -292,11 +292,11 @@ int sr_cd_check(struct cdrom_device_info *cdi)
} }
cd->ms_offset = sector; cd->ms_offset = sector;
cd->xa_flag = 0; cd->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(cd))
cd->xa_flag = 1; cd->xa_flag = 1;
if (2048 != cd->device->sector_size) { if (2048 != cd->device->sector_size) {
sr_set_blocklength(minor, 2048); sr_set_blocklength(cd, 2048);
} }
if (no_multi) if (no_multi)
cdi->mask |= CDC_MULTI_SESSION; cdi->mask |= CDC_MULTI_SESSION;
......
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