Commit c7633c22 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (11/25) sr.c naming cleanup

	Global search'n'replace job - 'SCp' (Scsi_CD pointer - I'm not kidding;
and yes, they spell it "Scsi") replaced with 'cd' (sr.c, sr_ioctl.c,
sr_vendor.c).
parent e342ff2e
......@@ -99,13 +99,13 @@ static int sr_packet(struct cdrom_device_info *, struct cdrom_generic_command *)
static void sr_release(struct cdrom_device_info *cdi)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
if (SCp->device->sector_size > 2048)
if (cd->device->sector_size > 2048)
sr_set_blocklength(minor(cdi->dev), 2048);
SCp->device->access_count--;
if (SCp->device->host->hostt->module)
__MOD_DEC_USE_COUNT(SCp->device->host->hostt->module);
cd->device->access_count--;
if (cd->device->host->hostt->module)
__MOD_DEC_USE_COUNT(cd->device->host->hostt->module);
if (sr_template.module)
__MOD_DEC_USE_COUNT(sr_template.module);
}
......@@ -146,7 +146,7 @@ static struct cdrom_device_ops sr_dops =
int sr_media_change(struct cdrom_device_info *cdi, int slot)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
int retval;
if (CDSL_CURRENT != slot) {
......@@ -154,19 +154,19 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
return -EINVAL;
}
retval = scsi_ioctl(SCp->device, SCSI_IOCTL_TEST_UNIT_READY, 0);
retval = scsi_ioctl(cd->device, SCSI_IOCTL_TEST_UNIT_READY, 0);
if (retval) {
/* Unable to test, unit probably not ready. This usually
* means there is no disc in the drive. Mark as changed,
* and we will figure it out later once the drive is
* available again. */
SCp->device->changed = 1;
cd->device->changed = 1;
return 1; /* This will force a flush, if called from
* check_disk_change */
};
retval = SCp->device->changed;
SCp->device->changed = 0;
retval = cd->device->changed;
cd->device->changed = 0;
/* If the disk changed, the capacity will now be different,
* so we force a re-read of this information */
if (retval) {
......@@ -180,8 +180,8 @@ int sr_media_change(struct cdrom_device_info *cdi, int slot)
* be trying to use something that is too small if the disc
* has changed.
*/
SCp->needs_sector_size = 1;
SCp->device->sector_size = 2048;
cd->needs_sector_size = 1;
cd->device->sector_size = 2048;
}
return retval;
}
......@@ -198,7 +198,7 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
int good_sectors = (result == 0 ? this_count : 0);
int block_sectors = 0;
int device_nr = DEVICE_NR(SCpnt->request->rq_dev);
Scsi_CD *SCp = &scsi_CDs[device_nr];
Scsi_CD *cd = &scsi_CDs[device_nr];
#ifdef DEBUG
printk("sr.c done: %x %p\n", result, SCpnt->request->bh->b_data);
......@@ -223,7 +223,7 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
block_sectors = bio_sectors(SCpnt->request->bio);
if (block_sectors < 4)
block_sectors = 4;
if (SCp->device->sector_size == 2048)
if (cd->device->sector_size == 2048)
error_sector <<= 2;
error_sector &= ~(block_sectors - 1);
good_sectors = error_sector - SCpnt->request->sector;
......@@ -236,7 +236,7 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
* 75 2K sectors, we decrease the saved size value.
*/
if ((error_sector >> 1) < sr_sizes[device_nr] &&
SCp->capacity - error_sector < 4 * 75)
cd->capacity - error_sector < 4 * 75)
sr_sizes[device_nr] = error_sector >> 1;
}
......@@ -251,34 +251,34 @@ static void rw_intr(Scsi_Cmnd * SCpnt)
static request_queue_t *sr_find_queue(kdev_t dev)
{
Scsi_CD *SCp;
Scsi_CD *cd;
if (minor(dev) >= sr_template.dev_max)
return NULL;
SCp = &scsi_CDs[minor(dev)];
if (!SCp->device)
cd = &scsi_CDs[minor(dev)];
if (!cd->device)
return NULL;
return &SCp->device->request_queue;
return &cd->device->request_queue;
}
static int sr_init_command(Scsi_Cmnd * SCpnt)
{
int dev, devm, block=0, this_count, s_size;
Scsi_CD *SCp;
Scsi_CD *cd;
devm = minor(SCpnt->request->rq_dev);
dev = DEVICE_NR(SCpnt->request->rq_dev);
SCp = &scsi_CDs[dev];
cd = &scsi_CDs[dev];
SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %d, block = %d\n", devm, block));
if (dev >= sr_template.nr_dev || !SCp->device || !SCp->device->online) {
if (dev >= sr_template.nr_dev || !cd->device || !cd->device->online) {
SCSI_LOG_HLQUEUE(2, printk("Finishing %ld sectors\n", SCpnt->request->nr_sectors));
SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt));
return 0;
}
if (SCp->device->changed) {
if (cd->device->changed) {
/*
* quietly refuse to do anything to a changed disc until the
* changed bit has been reset
......@@ -295,7 +295,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
* we do lazy blocksize switching (when reading XA sectors,
* see CDROMREADMODE2 ioctl)
*/
s_size = SCp->device->sector_size;
s_size = cd->device->sector_size;
if (s_size > 2048) {
if (!in_interrupt())
sr_set_blocklength(DEVICE_NR(CURRENT->rq_dev), 2048);
......@@ -309,7 +309,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
}
if (rq_data_dir(SCpnt->request) == WRITE) {
if (!SCp->device->writeable)
if (!cd->device->writeable)
return 0;
SCpnt->cmnd[0] = WRITE_10;
SCpnt->sc_data_direction = SCSI_DATA_WRITE;
......@@ -333,7 +333,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%ld 512 byte blocks.\n",
SCp->cdi.name,
cd->cdi.name,
(rq_data_dir(SCpnt->request) == WRITE) ? "writing" : "reading",
this_count, SCpnt->request->nr_sectors));
......@@ -358,7 +358,7 @@ static int sr_init_command(Scsi_Cmnd * SCpnt)
* host adapter, it's safe to assume that we can at least transfer
* this many bytes between each connect / disconnect.
*/
SCpnt->transfersize = SCp->device->sector_size;
SCpnt->transfersize = cd->device->sector_size;
SCpnt->underflow = this_count << 9;
SCpnt->allowed = MAX_RETRIES;
......@@ -400,21 +400,21 @@ struct block_device_operations sr_bdops =
static int sr_open(struct cdrom_device_info *cdi, int purpose)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
if (minor(cdi->dev) >= sr_template.dev_max || !SCp->device) {
if (minor(cdi->dev) >= sr_template.dev_max || !cd->device) {
return -ENXIO; /* No such device */
}
/*
* If the device is in error recovery, wait until it is done.
* If the device is offline, then disallow any access to it.
*/
if (!scsi_block_when_processing_errors(SCp->device)) {
if (!scsi_block_when_processing_errors(cd->device)) {
return -ENXIO;
}
SCp->device->access_count++;
if (SCp->device->host->hostt->module)
__MOD_INC_USE_COUNT(SCp->device->host->hostt->module);
cd->device->access_count++;
if (cd->device->host->hostt->module)
__MOD_INC_USE_COUNT(cd->device->host->hostt->module);
if (sr_template.module)
__MOD_INC_USE_COUNT(sr_template.module);
......@@ -423,7 +423,7 @@ static int sr_open(struct cdrom_device_info *cdi, int purpose)
* this is the case, and try again.
*/
if (SCp->needs_sector_size)
if (cd->needs_sector_size)
get_sectorsize(minor(cdi->dev));
return 0;
......@@ -477,22 +477,22 @@ void get_sectorsize(int i)
int the_result, retries = 3;
int sector_size;
Scsi_Request *SRpnt = NULL;
Scsi_CD *SCp;
Scsi_CD *cd;
request_queue_t *queue;
SCp = &scsi_CDs[i];
cd = &scsi_CDs[i];
buffer = kmalloc(512, GFP_DMA);
if (!buffer)
goto Enomem;
SRpnt = scsi_allocate_request(SCp->device);
SRpnt = scsi_allocate_request(cd->device);
if (!SRpnt)
goto Enomem;
do {
cmd[0] = READ_CAPACITY;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun << 5) & 0xe0) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun << 5) & 0xe0) : 0;
memset((void *) &cmd[2], 0, 8);
SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; /* Mark as really busy */
SRpnt->sr_cmd_len = 0;
......@@ -515,15 +515,15 @@ void get_sectorsize(int i)
SRpnt = NULL;
if (the_result) {
SCp->capacity = 0x1fffff;
cd->capacity = 0x1fffff;
sector_size = 2048; /* A guess, just in case */
SCp->needs_sector_size = 1;
cd->needs_sector_size = 1;
} else {
#if 0
if (cdrom_get_last_written(&SCp->cdi,
&SCp->capacity))
if (cdrom_get_last_written(&cd->cdi,
&cd->capacity))
#endif
SCp->capacity = 1 + ((buffer[0] << 24) |
cd->capacity = 1 + ((buffer[0] << 24) |
(buffer[1] << 16) |
(buffer[2] << 8) |
buffer[3]);
......@@ -542,37 +542,37 @@ void get_sectorsize(int i)
sector_size = 2048;
/* fall through */
case 2048:
SCp->capacity *= 4;
cd->capacity *= 4;
/* fall through */
case 512:
break;
default:
printk("%s: unsupported sector size %d.\n",
SCp->cdi.name, sector_size);
SCp->capacity = 0;
SCp->needs_sector_size = 1;
cd->cdi.name, sector_size);
cd->capacity = 0;
cd->needs_sector_size = 1;
}
SCp->device->sector_size = sector_size;
cd->device->sector_size = sector_size;
/*
* Add this so that we have the ability to correctly gauge
* what the device is capable of.
*/
SCp->needs_sector_size = 0;
sr_sizes[i] = SCp->capacity >> (BLOCK_SIZE_BITS - 9);
cd->needs_sector_size = 0;
sr_sizes[i] = cd->capacity >> (BLOCK_SIZE_BITS - 9);
}
queue = &SCp->device->request_queue;
queue = &cd->device->request_queue;
blk_queue_hardsect_size(queue, sector_size);
out:
kfree(buffer);
return;
Enomem:
SCp->capacity = 0x1fffff;
cd->capacity = 0x1fffff;
sector_size = 2048; /* A guess, just in case */
SCp->needs_sector_size = 1;
cd->needs_sector_size = 1;
if (SRpnt)
scsi_release_request(SRpnt);
goto out;
......@@ -580,7 +580,7 @@ void get_sectorsize(int i)
void get_capabilities(int i)
{
Scsi_CD *SCp;
Scsi_CD *cd;
unsigned char cmd[6];
unsigned char *buffer;
int rc, n;
......@@ -597,7 +597,7 @@ void get_capabilities(int i)
""
};
SCp = &scsi_CDs[i];
cd = &scsi_CDs[i];
buffer = kmalloc(512, GFP_DMA);
if (!buffer)
{
......@@ -605,8 +605,8 @@ void get_capabilities(int i)
return;
}
cmd[0] = MODE_SENSE;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun << 5) & 0xe0) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun << 5) & 0xe0) : 0;
cmd[2] = 0x2a;
cmd[4] = 128;
cmd[3] = cmd[5] = 0;
......@@ -614,22 +614,22 @@ void get_capabilities(int i)
if (rc) {
/* failed, drive doesn't have capabilities mode page */
SCp->cdi.speed = 1;
SCp->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
cd->cdi.speed = 1;
cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
CDC_DVD | CDC_DVD_RAM |
CDC_SELECT_DISC | CDC_SELECT_SPEED);
kfree(buffer);
printk("%s: scsi-1 drive\n", SCp->cdi.name);
printk("%s: scsi-1 drive\n", cd->cdi.name);
return;
}
n = buffer[3] + 4;
SCp->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
SCp->readcd_known = 1;
SCp->readcd_cdda = buffer[n + 5] & 0x01;
cd->cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
cd->readcd_known = 1;
cd->readcd_cdda = buffer[n + 5] & 0x01;
/* print some capability bits */
printk("%s: scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n", SCp->cdi.name,
printk("%s: scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n", cd->cdi.name,
((buffer[n + 14] << 8) + buffer[n + 15]) / 176,
SCp->cdi.speed,
cd->cdi.speed,
buffer[n + 3] & 0x01 ? "writer " : "", /* CD Writer */
buffer[n + 3] & 0x20 ? "dvd-ram " : "",
buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
......@@ -638,38 +638,38 @@ void get_capabilities(int i)
loadmech[buffer[n + 6] >> 5]);
if ((buffer[n + 6] >> 5) == 0)
/* caddy drives can't close tray... */
SCp->cdi.mask |= CDC_CLOSE_TRAY;
cd->cdi.mask |= CDC_CLOSE_TRAY;
if ((buffer[n + 2] & 0x8) == 0)
/* not a DVD drive */
SCp->cdi.mask |= CDC_DVD;
cd->cdi.mask |= CDC_DVD;
if ((buffer[n + 3] & 0x20) == 0) {
/* can't write DVD-RAM media */
SCp->cdi.mask |= CDC_DVD_RAM;
cd->cdi.mask |= CDC_DVD_RAM;
} else {
SCp->device->writeable = 1;
cd->device->writeable = 1;
}
if ((buffer[n + 3] & 0x10) == 0)
/* can't write DVD-R media */
SCp->cdi.mask |= CDC_DVD_R;
cd->cdi.mask |= CDC_DVD_R;
if ((buffer[n + 3] & 0x2) == 0)
/* can't write CD-RW media */
SCp->cdi.mask |= CDC_CD_RW;
cd->cdi.mask |= CDC_CD_RW;
if ((buffer[n + 3] & 0x1) == 0)
/* can't write CD-R media */
SCp->cdi.mask |= CDC_CD_R;
cd->cdi.mask |= CDC_CD_R;
if ((buffer[n + 6] & 0x8) == 0)
/* can't eject */
SCp->cdi.mask |= CDC_OPEN_TRAY;
cd->cdi.mask |= CDC_OPEN_TRAY;
if ((buffer[n + 6] >> 5) == mechtype_individual_changer ||
(buffer[n + 6] >> 5) == mechtype_cartridge_changer)
SCp->cdi.capacity =
cdrom_number_of_slots(&SCp->cdi);
if (SCp->cdi.capacity <= 1)
cd->cdi.capacity =
cdrom_number_of_slots(&cd->cdi);
if (cd->cdi.capacity <= 1)
/* not a changer */
SCp->cdi.mask |= CDC_SELECT_DISC;
cd->cdi.mask |= CDC_SELECT_DISC;
/*else I don't think it can close its tray
SCp->cdi.mask |= CDC_CLOSE_TRAY; */
cd->cdi.mask |= CDC_CLOSE_TRAY; */
kfree(buffer);
}
......@@ -680,8 +680,8 @@ void get_capabilities(int i)
*/
static int sr_packet(struct cdrom_device_info *cdi, struct cdrom_generic_command *cgc)
{
Scsi_CD *SCp = cdi->handle;
Scsi_Device *device = SCp->device;
Scsi_CD *cd = cdi->handle;
Scsi_Device *device = cd->device;
/* set the LUN */
if (device->scsi_level <= SCSI_2)
......@@ -758,59 +758,59 @@ void sr_finish()
blk_size[MAJOR_NR] = sr_sizes;
for (i = 0; i < sr_template.nr_dev; ++i) {
Scsi_CD *SCp = &scsi_CDs[i];
Scsi_CD *cd = &scsi_CDs[i];
/* If we have already seen this, then skip it. Comes up
* with loadable modules. */
if (SCp->capacity)
if (cd->capacity)
continue;
SCp->capacity = 0x1fffff;
SCp->device->sector_size = 2048;/* A guess, just in case */
SCp->needs_sector_size = 1;
SCp->device->changed = 1; /* force recheck CD type */
cd->capacity = 0x1fffff;
cd->device->sector_size = 2048;/* A guess, just in case */
cd->needs_sector_size = 1;
cd->device->changed = 1; /* force recheck CD type */
#if 0
/* seems better to leave this for later */
get_sectorsize(i);
printk("Scd sectorsize = %d bytes.\n", SCp->sector_size);
printk("Scd sectorsize = %d bytes.\n", cd->sector_size);
#endif
SCp->use = 1;
SCp->device->ten = 1;
SCp->device->remap = 1;
SCp->readcd_known = 0;
SCp->readcd_cdda = 0;
sr_sizes[i] = SCp->capacity >> (BLOCK_SIZE_BITS - 9);
SCp->cdi.ops = &sr_dops;
SCp->cdi.handle = SCp;
SCp->cdi.dev = mk_kdev(MAJOR_NR, i);
SCp->cdi.mask = 0;
SCp->cdi.capacity = 1;
cd->use = 1;
cd->device->ten = 1;
cd->device->remap = 1;
cd->readcd_known = 0;
cd->readcd_cdda = 0;
sr_sizes[i] = cd->capacity >> (BLOCK_SIZE_BITS - 9);
cd->cdi.ops = &sr_dops;
cd->cdi.handle = cd;
cd->cdi.dev = mk_kdev(MAJOR_NR, i);
cd->cdi.mask = 0;
cd->cdi.capacity = 1;
/*
* FIXME: someone needs to handle a get_capabilities
* failure properly ??
*/
get_capabilities(i);
sr_vendor_init(SCp);
sprintf(SCp->cdi.cdrom_driverfs_dev.bus_id, "%s:cd",
SCp->device->sdev_driverfs_dev.bus_id);
sprintf(SCp->cdi.cdrom_driverfs_dev.name, "%scdrom",
SCp->device->sdev_driverfs_dev.name);
SCp->cdi.cdrom_driverfs_dev.parent =
&SCp->device->sdev_driverfs_dev;
SCp->cdi.cdrom_driverfs_dev.bus = &scsi_driverfs_bus_type;
SCp->cdi.cdrom_driverfs_dev.driver_data =
sr_vendor_init(cd);
sprintf(cd->cdi.cdrom_driverfs_dev.bus_id, "%s:cd",
cd->device->sdev_driverfs_dev.bus_id);
sprintf(cd->cdi.cdrom_driverfs_dev.name, "%scdrom",
cd->device->sdev_driverfs_dev.name);
cd->cdi.cdrom_driverfs_dev.parent =
&cd->device->sdev_driverfs_dev;
cd->cdi.cdrom_driverfs_dev.bus = &scsi_driverfs_bus_type;
cd->cdi.cdrom_driverfs_dev.driver_data =
(void *)(long)__mkdev(MAJOR_NR, i);
device_register(&SCp->cdi.cdrom_driverfs_dev);
device_create_file(&SCp->cdi.cdrom_driverfs_dev,
device_register(&cd->cdi.cdrom_driverfs_dev);
device_create_file(&cd->cdi.cdrom_driverfs_dev,
&dev_attr_type);
device_create_file(&SCp->cdi.cdrom_driverfs_dev,
device_create_file(&cd->cdi.cdrom_driverfs_dev,
&dev_attr_kdev);
SCp->cdi.de = devfs_register(SCp->device->de, "cd",
cd->cdi.de = devfs_register(cd->device->de, "cd",
DEVFS_FL_DEFAULT, MAJOR_NR, i,
S_IFBLK | S_IRUGO | S_IWUGO,
&sr_bdops, NULL);
register_cdrom(&SCp->cdi);
register_cdrom(&cd->cdi);
}
}
......
......@@ -194,25 +194,25 @@ int sr_do_ioctl(int target, unsigned char *sr_cmd, void *buffer, unsigned buflen
static int test_unit_ready(int minor)
{
Scsi_CD *SCp;
Scsi_CD *cd;
u_char sr_cmd[10];
SCp = &scsi_CDs[minor];
cd = &scsi_CDs[minor];
sr_cmd[0] = GPCMD_TEST_UNIT_READY;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->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);
}
int sr_tray_move(struct cdrom_device_info *cdi, int pos)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
u_char sr_cmd[10];
sr_cmd[0] = GPCMD_START_STOP_UNIT;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
sr_cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ;
......@@ -221,9 +221,9 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos)
int sr_lock_door(struct cdrom_device_info *cdi, int lock)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
return scsi_ioctl(SCp->device, lock ? SCSI_IOCTL_DOORLOCK :
return scsi_ioctl(cd->device, lock ? SCSI_IOCTL_DOORLOCK :
SCSI_IOCTL_DOORUNLOCK, 0);
}
......@@ -241,7 +241,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
int sr_disk_status(struct cdrom_device_info *cdi)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
struct cdrom_tochdr toc_h;
struct cdrom_tocentry toc_e;
int i, rc, have_datatracks = 0;
......@@ -263,7 +263,7 @@ int sr_disk_status(struct cdrom_device_info *cdi)
if (!have_datatracks)
return CDS_AUDIO;
if (SCp->xa_flag)
if (cd->xa_flag)
return CDS_XA_2_1;
else
return CDS_DATA_1;
......@@ -272,24 +272,24 @@ int sr_disk_status(struct cdrom_device_info *cdi)
int sr_get_last_session(struct cdrom_device_info *cdi,
struct cdrom_multisession *ms_info)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
ms_info->addr.lba = SCp->ms_offset;
ms_info->xa_flag = SCp->xa_flag || SCp->ms_offset > 0;
ms_info->addr.lba = cd->ms_offset;
ms_info->xa_flag = cd->xa_flag || cd->ms_offset > 0;
return 0;
}
int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
u_char sr_cmd[10];
char buffer[32];
int result;
sr_cmd[0] = GPCMD_READ_SUBCHANNEL;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->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;
......@@ -314,7 +314,7 @@ int sr_reset(struct cdrom_device_info *cdi)
int sr_select_speed(struct cdrom_device_info *cdi, int speed)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
u_char sr_cmd[MAX_COMMAND_SIZE];
if (speed == 0)
......@@ -324,8 +324,8 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
memset(sr_cmd, 0, MAX_COMMAND_SIZE);
sr_cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun) << 5) : 0;
sr_cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */
sr_cmd[3] = speed & 0xff; /* LSB */
......@@ -342,7 +342,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)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
u_char sr_cmd[10];
int result, target = minor(cdi->dev);
unsigned char buffer[32];
......@@ -355,8 +355,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->device->lun) << 5) : 0;
sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
sr_cmd[8] = 12; /* LSB of length */
......@@ -373,8 +373,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_tocentry *tocentry = (struct cdrom_tocentry *) arg;
sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
((SCp->device->lun) << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
((cd->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;
......@@ -400,8 +400,8 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
struct cdrom_ti* ti = (struct cdrom_ti*)arg;
sr_cmd[0] = GPCMD_PLAYAUDIO_TI;
sr_cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
sr_cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
sr_cmd[4] = ti->cdti_trk0;
sr_cmd[5] = ti->cdti_ind0;
sr_cmd[7] = ti->cdti_trk1;
......@@ -443,17 +443,17 @@ 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)
{
unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_CD *SCp = &scsi_CDs[minor];
Scsi_CD *cd = &scsi_CDs[minor];
#ifdef DEBUG
printk("%s: sr_read_cd lba=%d format=%d blksize=%d\n",
SCp->cdi.name, lba, format, blksize);
cd->cdi.name, lba, format, blksize);
#endif
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_CD; /* READ_CD */
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[1] |= ((format & 7) << 2);
cmd[2] = (unsigned char) (lba >> 24) & 0xff;
cmd[3] = (unsigned char) (lba >> 16) & 0xff;
......@@ -484,31 +484,31 @@ 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)
{
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
Scsi_CD *SCp = &scsi_CDs[minor];
Scsi_CD *cd = &scsi_CDs[minor];
int rc;
/* we try the READ CD command first... */
if (SCp->readcd_known) {
if (cd->readcd_known) {
rc = sr_read_cd(minor, dest, lba, 0, blksize);
if (-EDRIVE_CANT_DO_THIS != rc)
return rc;
SCp->readcd_known = 0;
cd->readcd_known = 0;
printk("CDROM does'nt support READ CD (0xbe) command\n");
/* fall & retry the other way */
}
/* ... if this fails, we switch the blocksize using MODE SELECT */
if (blksize != SCp->device->sector_size) {
if (blksize != cd->device->sector_size) {
if (0 != (rc = sr_set_blocklength(minor, blksize)))
return rc;
}
#ifdef DEBUG
printk("%s: sr_read_sector lba=%d blksize=%d\n", SCp->cdi.name, lba, blksize);
printk("%s: sr_read_sector lba=%d blksize=%d\n", cd->cdi.name, lba, blksize);
#endif
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = GPCMD_READ_10;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->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;
......@@ -527,7 +527,7 @@ int sr_read_sector(int minor, int lba, int blksize, unsigned char *dest)
int sr_is_xa(int minor)
{
unsigned char *raw_sector;
Scsi_CD *SCp = &scsi_CDs[minor];
Scsi_CD *cd = &scsi_CDs[minor];
int is_xa;
if (!xa_test)
......@@ -536,7 +536,7 @@ int sr_is_xa(int minor)
raw_sector = (unsigned char *) kmalloc(2048, GFP_DMA | GFP_KERNEL);
if (!raw_sector)
return -ENOMEM;
if (0 == sr_read_sector(minor, SCp->ms_offset + 16,
if (0 == sr_read_sector(minor, cd->ms_offset + 16,
CD_FRAMESIZE_RAW1, raw_sector)) {
is_xa = (raw_sector[3] == 0x02) ? 1 : 0;
} else {
......@@ -545,7 +545,7 @@ int sr_is_xa(int minor)
}
kfree(raw_sector);
#ifdef DEBUG
printk("%s: sr_is_xa: %d\n", SCp->cdi.name, is_xa);
printk("%s: sr_is_xa: %d\n", cd->cdi.name, is_xa);
#endif
return is_xa;
}
......@@ -553,16 +553,16 @@ int sr_is_xa(int minor)
int sr_dev_ioctl(struct cdrom_device_info *cdi,
unsigned int cmd, unsigned long arg)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
switch (cmd) {
case BLKGETSIZE:
return put_user(SCp->capacity, (unsigned long *) arg);
return put_user(cd->capacity, (unsigned long *) arg);
case BLKGETSIZE64:
return put_user((u64)SCp->capacity << 9, (u64 *)arg);
return put_user((u64)cd->capacity << 9, (u64 *)arg);
default:
return scsi_ioctl(SCp->device, cmd, (void *)arg);
return scsi_ioctl(cd->device, cmd, (void *)arg);
}
}
......
......@@ -58,25 +58,25 @@
#define VENDOR_TOSHIBA 3
#define VENDOR_WRITER 4 /* pre-scsi3 writers */
void sr_vendor_init(Scsi_CD *SCp)
void sr_vendor_init(Scsi_CD *cd)
{
#ifndef CONFIG_BLK_DEV_SR_VENDOR
SCp->vendor = VENDOR_SCSI3;
cd->vendor = VENDOR_SCSI3;
#else
char *vendor = SCp->device->vendor;
char *model = SCp->device->model;
char *vendor = cd->device->vendor;
char *model = cd->device->model;
/* default */
SCp->vendor = VENDOR_SCSI3;
if (SCp->readcd_known)
cd->vendor = VENDOR_SCSI3;
if (cd->readcd_known)
/* this is true for scsi3/mmc drives - no more checks */
return;
if (SCp->device->type == TYPE_WORM) {
SCp->vendor = VENDOR_WRITER;
if (cd->device->type == TYPE_WORM) {
cd->vendor = VENDOR_WRITER;
} else if (!strncmp(vendor, "NEC", 3)) {
SCp->vendor = VENDOR_NEC;
cd->vendor = VENDOR_NEC;
if (!strncmp(model, "CD-ROM DRIVE:25", 15) ||
!strncmp(model, "CD-ROM DRIVE:36", 15) ||
!strncmp(model, "CD-ROM DRIVE:83", 15) ||
......@@ -88,10 +88,10 @@ void sr_vendor_init(Scsi_CD *SCp)
#endif
)
/* these can't handle multisession, may hang */
SCp->cdi.mask |= CDC_MULTI_SESSION;
cd->cdi.mask |= CDC_MULTI_SESSION;
} else if (!strncmp(vendor, "TOSHIBA", 7)) {
SCp->vendor = VENDOR_TOSHIBA;
cd->vendor = VENDOR_TOSHIBA;
}
#endif
......@@ -106,11 +106,11 @@ int sr_set_blocklength(int minor, int blocklength)
unsigned char *buffer; /* the buffer for the ioctl */
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
struct ccs_modesel_head *modesel;
Scsi_CD *SCp = &scsi_CDs[minor];
Scsi_CD *cd = &scsi_CDs[minor];
int rc, density = 0;
#ifdef CONFIG_BLK_DEV_SR_VENDOR
if (SCp->vendor == VENDOR_TOSHIBA)
if (cd->vendor == VENDOR_TOSHIBA)
density = (blocklength > 2048) ? 0x81 : 0x83;
#endif
......@@ -119,12 +119,12 @@ int sr_set_blocklength(int minor, int blocklength)
return -ENOMEM;
#ifdef DEBUG
printk("%s: MODE SELECT 0x%x/%d\n", SCp->cdi.name, density, blocklength);
printk("%s: MODE SELECT 0x%x/%d\n", cd->cdi.name, density, blocklength);
#endif
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = MODE_SELECT;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[1] |= (1 << 4);
cmd[4] = 12;
modesel = (struct ccs_modesel_head *) buffer;
......@@ -134,12 +134,12 @@ int sr_set_blocklength(int minor, int blocklength)
modesel->block_length_med = (blocklength >> 8) & 0xff;
modesel->block_length_lo = blocklength & 0xff;
if (0 == (rc = sr_do_ioctl(minor, cmd, buffer, sizeof(*modesel), 0, SCSI_DATA_WRITE, NULL))) {
SCp->device->sector_size = blocklength;
cd->device->sector_size = blocklength;
}
#ifdef DEBUG
else
printk("%s: switching blocklength to %d bytes failed\n",
SCp->cdi.name, blocklength);
cd->cdi.name, blocklength);
#endif
kfree(buffer);
return rc;
......@@ -152,14 +152,14 @@ int sr_set_blocklength(int minor, int blocklength)
int sr_cd_check(struct cdrom_device_info *cdi)
{
Scsi_CD *SCp = cdi->handle;
Scsi_CD *cd = cdi->handle;
unsigned long sector;
unsigned char *buffer; /* the buffer for the ioctl */
unsigned char cmd[MAX_COMMAND_SIZE]; /* the scsi-command */
int rc, no_multi, minor;
minor = minor(cdi->dev);
if (SCp->cdi.mask & CDC_MULTI_SESSION)
if (cd->cdi.mask & CDC_MULTI_SESSION)
return 0;
buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA);
......@@ -170,13 +170,13 @@ int sr_cd_check(struct cdrom_device_info *cdi)
no_multi = 0; /* flag: the drive can't handle multisession */
rc = 0;
switch (SCp->vendor) {
switch (cd->vendor) {
case VENDOR_SCSI3:
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = READ_TOC;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[8] = 12;
cmd[9] = 0x40;
rc = sr_do_ioctl(minor, cmd, buffer, 12, 1, SCSI_DATA_READ, NULL);
......@@ -184,7 +184,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
break;
if ((buffer[0] << 8) + buffer[1] < 0x0a) {
printk(KERN_INFO "%s: Hmm, seems the drive "
"doesn't support multisession CD's\n", SCp->cdi.name);
"doesn't support multisession CD's\n", cd->cdi.name);
no_multi = 1;
break;
}
......@@ -201,8 +201,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
unsigned long min, sec, frame;
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = 0xde;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[1] |= 0x03;
cmd[2] = 0xb0;
rc = sr_do_ioctl(minor, cmd, buffer, 0x16, 1, SCSI_DATA_READ, NULL);
......@@ -210,7 +210,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
break;
if (buffer[14] != 0 && buffer[14] != 0xb0) {
printk(KERN_INFO "%s: Hmm, seems the cdrom "
"doesn't support multisession CD's\n", SCp->cdi.name);
"doesn't support multisession CD's\n", cd->cdi.name);
no_multi = 1;
break;
}
......@@ -228,13 +228,13 @@ int sr_cd_check(struct cdrom_device_info *cdi)
* where starts the last session ?) */
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = 0xc7;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[1] |= 0x03;
rc = sr_do_ioctl(minor, cmd, buffer, 4, 1, SCSI_DATA_READ, NULL);
if (rc == -EINVAL) {
printk(KERN_INFO "%s: Hmm, seems the drive "
"doesn't support multisession CD's\n", SCp->cdi.name);
"doesn't support multisession CD's\n", cd->cdi.name);
no_multi = 1;
break;
}
......@@ -253,8 +253,8 @@ int sr_cd_check(struct cdrom_device_info *cdi)
case VENDOR_WRITER:
memset(cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = READ_TOC;
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[8] = 0x04;
cmd[9] = 0x40;
rc = sr_do_ioctl(minor, cmd, buffer, 0x04, 1, SCSI_DATA_READ, NULL);
......@@ -263,12 +263,12 @@ int sr_cd_check(struct cdrom_device_info *cdi)
}
if ((rc = buffer[2]) == 0) {
printk(KERN_WARNING
"%s: No finished session\n", SCp->cdi.name);
"%s: No finished session\n", cd->cdi.name);
break;
}
cmd[0] = READ_TOC; /* Read TOC */
cmd[1] = (SCp->device->scsi_level <= SCSI_2) ?
(SCp->device->lun << 5) : 0;
cmd[1] = (cd->device->scsi_level <= SCSI_2) ?
(cd->device->lun << 5) : 0;
cmd[6] = rc & 0x7f; /* number of last session */
cmd[8] = 0x0c;
cmd[9] = 0x40;
......@@ -285,17 +285,17 @@ int sr_cd_check(struct cdrom_device_info *cdi)
/* should not happen */
printk(KERN_WARNING
"%s: unknown vendor code (%i), not initialized ?\n",
SCp->cdi.name, SCp->vendor);
cd->cdi.name, cd->vendor);
sector = 0;
no_multi = 1;
break;
}
SCp->ms_offset = sector;
SCp->xa_flag = 0;
cd->ms_offset = sector;
cd->xa_flag = 0;
if (CDS_AUDIO != sr_disk_status(cdi) && 1 == sr_is_xa(minor))
SCp->xa_flag = 1;
cd->xa_flag = 1;
if (2048 != SCp->device->sector_size) {
if (2048 != cd->device->sector_size) {
sr_set_blocklength(minor, 2048);
}
if (no_multi)
......@@ -304,7 +304,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
#ifdef DEBUG
if (sector)
printk(KERN_DEBUG "%s: multisession offset=%lu\n",
SCp->cdi.name, sector);
cd->cdi.name, sector);
#endif
kfree(buffer);
return rc;
......
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