Commit 21aecbc3 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.8 IDE 34

- Synchronize with 2.5.8.

- Eliminate the cdrom_log_sense() function.

- Pass a struct request to cdrom_analyze_sense_data() since this is the entity
   this function is working on. This shows nicely that this function is broken.

- Use CDROM_PACKET_SIZE where appropriate.

- Kill the obfuscating cmd_buf and cmd_len local variables from
   cdrom_transfer_packet_command(). This made it obvious that the parameters of
   this function where not adequate - to say the least. Fix this.

- Pass a packed command array directly to cdrom_queue_packed_command().  This
   is reducing the number of places where we have to deal with the c member of
   struct packet_command.

- Never pass NULL as sense to cdrom_lockdoor().

- Eliminate cdrom_do_block_pc().

- Eliminate the c member of struct packet_command. Pass them through struct
   request cmd member.

- Don't enable TCQ unconditionally if there is a TCQ queue depth defined.

- Fix small think in ide_cmd_ioctl() rewrite. (My appologies to everyone who
   has to use hdparm to setup his system...)

- Fix compilation without PCI support.
parent e9dc26cd
/*
* linux/drivers/ide/ide-cd.c
*
* Copyright (C) 1994, 1995, 1996 scott snyder <snyder@fnald0.fnal.gov>
* Copyright (C) 1996-1998 Erik Andersen <andersee@debian.org>
* Copyright (C) 1998-2000 Jens Axboe <axboe@suse.de>
......@@ -16,6 +14,7 @@
* and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI
* (SFF-8020i rev 2.6) standards. These documents can be obtained by
* anonymous ftp from:
*
* ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps
* ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf
*
......@@ -164,7 +163,7 @@
*
* 4.03 Dec 04, 1996 -- Added DSC overlap support.
* 4.04 Dec 29, 1996 -- Added CDROMREADRAW ioclt based on patch
* by Ales Makarov (xmakarov@sun.felk.cvut.cz)
* by Aleks Makarov (xmakarov@sun.felk.cvut.cz)
*
* 4.05 Nov 20, 1997 -- Modified to print more drive info on init
* Minor other changes
......@@ -332,57 +331,62 @@ static void cdrom_saw_media_change (ide_drive_t *drive)
info->nsectors_buffered = 0;
}
static int cdrom_log_sense(ide_drive_t *drive, struct packet_command *pc,
struct request_sense *sense)
static
void cdrom_analyze_sense_data(ide_drive_t *drive, struct request *rq)
{
int log = 0;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
struct packet_command *failed_command = (struct packet_command *) pc->sense;
struct request_sense *sense = (struct request_sense *) (pc->buffer - rq->cmd[4]);
unsigned char fail_cmd;
if (sense == NULL || pc == NULL || pc->quiet)
return 0;
if (sense == NULL || failed_command == NULL || failed_command->quiet)
return;
fail_cmd = rq->cmd[0];
/* Check whatever this error should be logged:
*/
switch (sense->sense_key) {
case NO_SENSE: case RECOVERED_ERROR:
case NO_SENSE:
case RECOVERED_ERROR:
break;
case NOT_READY:
/*
* don't care about tray state messages for
* e.g. capacity commands or in-progress or
* becoming ready
/* Don't care about tray state messages for e.g.
* capacity commands or in-progress or becoming ready.
*/
if (sense->asc == 0x3a || sense->asc == 0x04)
break;
log = 1;
break;
case UNIT_ATTENTION:
/*
* Make good and sure we've seen this potential media
/* Make good and sure we've seen this potential media
* change. Some drives (i.e. Creative) fail to present
* the correct sense key in the error register.
*/
cdrom_saw_media_change(drive);
break;
default:
log = 1;
break;
}
return log;
}
static
void cdrom_analyze_sense_data(ide_drive_t *drive,
struct packet_command *failed_command,
struct request_sense *sense)
{
if (!cdrom_log_sense(drive, failed_command, sense))
if (!log)
return;
/*
* If a read toc is executed for a CD-R or CD-RW medium where
* the first toc has not been recorded yet, it will fail with
* 05/24/00 (which is a confusing error)
* If a read toc is executed for a CD-R or CD-RW medium where the first
* toc has not been recorded yet, it will fail with 05/24/00 (which is
* a confusing error).
*/
if (failed_command && failed_command->c[0] == GPCMD_READ_TOC_PMA_ATIP)
if (fail_cmd == GPCMD_READ_TOC_PMA_ATIP)
if (sense->sense_key == 0x05 && sense->asc == 0x24)
return;
......@@ -445,28 +449,26 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
printk(" %s -- (asc=0x%02x, ascq=0x%02x)\n",
s, sense->asc, sense->ascq);
if (failed_command != NULL) {
{
int lo=0, mid, hi= ARY_LEN (packet_command_texts);
s = NULL;
while (hi > lo) {
mid = (lo + hi) / 2;
if (packet_command_texts[mid].packet_command ==
failed_command->c[0]) {
if (packet_command_texts[mid].packet_command == fail_cmd) {
s = packet_command_texts[mid].text;
break;
}
if (packet_command_texts[mid].packet_command >
failed_command->c[0])
if (packet_command_texts[mid].packet_command > fail_cmd)
hi = mid;
else
lo = mid+1;
}
printk (" The failed \"%s\" packet command was: \n \"", s);
for (i=0; i<sizeof (failed_command->c); i++)
printk ("%02x ", failed_command->c[i]);
for (i=0; i < CDROM_PACKET_SIZE; i++)
printk ("%02x ", rq->cmd[i]);
printk ("\"\n");
}
......@@ -495,7 +497,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
}
}
#else /* not VERBOSE_IDE_CD_ERRORS */
#else
/* Suppress printing unit attention and `in progress of becoming ready'
errors when we're not being verbose. */
......@@ -509,7 +511,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
drive->name,
sense->error_code, sense->sense_key,
sense->asc, sense->ascq);
#endif /* not VERBOSE_IDE_CD_ERRORS */
#endif
}
static void cdrom_queue_request_sense(ide_drive_t *drive,
......@@ -525,16 +527,20 @@ static void cdrom_queue_request_sense(ide_drive_t *drive,
sense = &info->sense_data;
memset(pc, 0, sizeof(struct packet_command));
pc->c[0] = GPCMD_REQUEST_SENSE;
pc->c[4] = pc->buflen = 18;
pc->buffer = (char *) sense;
pc->buffer = (void *) sense;
pc->buflen = 18;
pc->sense = (struct request_sense *) failed_command;
/* stuff the sense request in front of our current request */
rq = &info->request_sense_request;
rq->cmd[0] = GPCMD_REQUEST_SENSE;
rq->cmd[4] = pc->buflen;
ide_init_drive_cmd(rq);
rq->flags = REQ_SENSE;
/* FIXME --mdcki */
rq->special = (char *) pc;
rq->waiting = wait;
ide_do_drive_cmd(drive, rq, ide_preempt);
}
......@@ -544,16 +550,13 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
if ((rq->flags & REQ_SENSE) && uptodate) {
struct packet_command *pc = (struct packet_command *) rq->special;
cdrom_analyze_sense_data(drive,
(struct packet_command *) pc->sense,
(struct request_sense *) (pc->buffer - pc->c[4]));
}
if ((rq->flags & REQ_SENSE) && uptodate)
cdrom_analyze_sense_data(drive, rq);
if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors)
uptodate = 1;
/* FIXME --mdcki */
HWGROUP(drive)->rq->special = NULL;
ide_end_request(drive, uptodate);
}
......@@ -590,6 +593,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
from the drive (probably while trying
to recover from a former error). Just give up. */
/* FIXME --mdcki */
pc = (struct packet_command *) rq->special;
pc->stat = 1;
cdrom_end_request(drive, 1);
......@@ -598,6 +602,8 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
} else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) {
/* All other functions, except for READ. */
struct completion *wait = NULL;
/* FIXME --mdcki */
pc = (struct packet_command *) rq->special;
/* Check for tray open. */
......@@ -614,13 +620,12 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
}
/* Set the error flag and complete the request.
Then, if we have a CHECK CONDITION status,
queue a request sense command. We must be careful,
though: we don't want the thread in
cdrom_queue_packet_command to wake up until
the request sense has completed. We do this
by transferring the semaphore from the packet
command request to the request sense request. */
Then, if we have a CHECK CONDITION status, queue a request
sense command. We must be careful, though: we don't want
the thread in cdrom_queue_packet_command to wake up until
the request sense has completed. We do this by transferring
the semaphore from the packet command request to the request
sense request. */
if ((stat & ERR_STAT) != 0) {
wait = rq->waiting;
......@@ -756,22 +761,15 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
}
}
/* Send a packet command to DRIVE described by CMD_BUF and CMD_LEN.
The device registers must have already been prepared
by cdrom_start_packet_command.
HANDLER is the interrupt handler to call when the command completes
or there's data ready. */
/*
* changed 5 parameters to 3 for dvd-ram
* struct packet_command *pc; now packet_command_t *pc;
* Send a packet command cmd to the drive. The device registers must have
* already been prepared by cdrom_start_packet_command. "handler" is the
* interrupt handler to call when the command completes or there's data ready.
*/
static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
struct packet_command *pc,
unsigned char *cmd, unsigned long timeout,
ide_handler_t *handler)
{
unsigned char *cmd_buf = pc->c;
int cmd_len = sizeof(pc->c);
unsigned int timeout = pc->timeout;
ide_startstop_t startstop;
if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
......@@ -780,20 +778,21 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
int stat_dum;
/* Check for errors. */
if (cdrom_decode_status (&startstop, drive, DRQ_STAT, &stat_dum))
if (cdrom_decode_status(&startstop, drive, DRQ_STAT, &stat_dum))
return startstop;
} else {
/* Otherwise, we must wait for DRQ to get set. */
if (ide_wait_stat (&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY))
if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY))
return startstop;
}
/* Arm the interrupt handler. */
BUG_ON(HWGROUP(drive)->handler);
ide_set_handler (drive, handler, timeout, cdrom_timer_expiry);
ide_set_handler(drive, handler, timeout, cdrom_timer_expiry);
/* Send the command to the device. */
atapi_output_bytes (drive, cmd_buf, cmd_len);
atapi_output_bytes(drive, cmd, CDROM_PACKET_SIZE);
return ide_started;
}
......@@ -889,7 +888,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
/*
* Interrupt routine. Called when a read request has completed.
*/
static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
{
int stat;
int ireason, len, sectors_to_transfer, nskip;
......@@ -1071,14 +1070,12 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
}
/*
* Routine to send a read packet command to the drive.
* This is usually called directly from cdrom_start_read.
* However, for drq_interrupt devices, it is called from an interrupt
* when the drive is ready to accept the command.
* Routine to send a read packet command to the drive. This is usually called
* directly from cdrom_start_read. However, for drq_interrupt devices, it is
* called from an interrupt when the drive is ready to accept the command.
*/
static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
static ide_startstop_t cdrom_start_read_continuation(ide_drive_t *drive)
{
struct packet_command pc;
struct request *rq = HWGROUP(drive)->rq;
int nsect, sector, nframes, frame, nskip;
......@@ -1117,15 +1114,11 @@ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
/* Largest number of frames was can transfer at once is 64k-1. For
some drives we need to limit this even more. */
nframes = MIN (nframes, (CDROM_CONFIG_FLAGS (drive)->limit_nframes) ?
nframes = MIN(nframes, (CDROM_CONFIG_FLAGS (drive)->limit_nframes) ?
(65534 / CD_FRAMESIZE) : 65535);
/* Set up the command */
memcpy(pc.c, rq->cmd, sizeof(pc.c));
pc.timeout = WAIT_CMD;
/* Send the command to the drive and return. */
return cdrom_transfer_packet_command(drive, &pc, &cdrom_read_intr);
return cdrom_transfer_packet_command(drive, rq->cmd, WAIT_CMD, &cdrom_read_intr);
}
......@@ -1161,7 +1154,7 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
{
struct packet_command pc;
unsigned char cmd[CDROM_PACKET_SIZE];
struct request *rq = HWGROUP(drive)->rq;
int sector, frame, nskip;
......@@ -1172,11 +1165,10 @@ static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
frame = sector / SECTORS_PER_FRAME;
memset(rq->cmd, 0, sizeof(rq->cmd));
pc.c[0] = GPCMD_SEEK;
put_unaligned(cpu_to_be32(frame), (unsigned int *) &pc.c[2]);
cmd[0] = GPCMD_SEEK;
put_unaligned(cpu_to_be32(frame), (unsigned int *) &cmd[2]);
pc.timeout = WAIT_CMD;
return cdrom_transfer_packet_command(drive, &pc, &cdrom_seek_intr);
return cdrom_transfer_packet_command(drive, cmd, WAIT_CMD, &cdrom_seek_intr);
}
static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
......@@ -1243,15 +1235,13 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
* Execute all other packet commands.
*/
/* Forward declarations. */
static int cdrom_lockdoor(ide_drive_t *drive, int lockflag,
struct request_sense *sense);
/* Interrupt routine for packet command completion. */
static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
{
int ireason, len, stat, thislen;
struct request *rq = HWGROUP(drive)->rq;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
ide_startstop_t startstop;
......@@ -1268,7 +1258,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
if ((stat & DRQ_STAT) == 0) {
/* Some of the trailing request sense fields are optional, and
some drives don't send them. Sigh. */
if (pc->c[0] == GPCMD_REQUEST_SENSE &&
if (rq->cmd[0] == GPCMD_REQUEST_SENSE &&
pc->buflen > 0 &&
pc->buflen <= 5) {
while (pc->buflen > 0) {
......@@ -1346,24 +1336,29 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
return ide_started;
}
static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive)
static ide_startstop_t cdrom_do_pc_continuation(ide_drive_t *drive)
{
struct request *rq = HWGROUP(drive)->rq;
unsigned long timeout;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
if (!pc->timeout)
pc->timeout = WAIT_CMD;
if (pc->timeout)
timeout = pc->timeout;
else
timeout = WAIT_CMD;
/* Send the command to the drive and return. */
return cdrom_transfer_packet_command(drive, pc, &cdrom_pc_intr);
return cdrom_transfer_packet_command(drive, rq->cmd, timeout, &cdrom_pc_intr);
}
static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
{
int len;
struct request *rq = HWGROUP(drive)->rq;
/* FIXME --mdcki */
struct packet_command *pc = (struct packet_command *) rq->special;
struct cdrom_info *info = drive->driver_data;
......@@ -1391,23 +1386,28 @@ void cdrom_sleep (int time)
}
static
int cdrom_queue_packet_command(ide_drive_t *drive, struct packet_command *pc)
int cdrom_queue_packet_command(ide_drive_t *drive, unsigned char *cmd, struct packet_command *pc)
{
struct request_sense sense;
struct request req;
struct request rq;
int retries = 10;
memcpy(rq.cmd, cmd, CDROM_PACKET_SIZE);
if (pc->sense == NULL)
pc->sense = &sense;
/* Start of retry loop. */
do {
ide_init_drive_cmd (&req);
req.flags = REQ_PC;
req.special = (char *) pc;
if (ide_do_drive_cmd (drive, &req, ide_wait)) {
ide_init_drive_cmd(&rq);
rq.flags = REQ_PC;
/* FIXME --mdcki */
rq.special = (void *) pc;
if (ide_do_drive_cmd(drive, &rq, ide_wait)) {
printk("%s: do_drive_cmd returned stat=%02x,err=%02x\n",
drive->name, req.buffer[0], req.buffer[1]);
drive->name, rq.buffer[0], rq.buffer[1]);
/* FIXME: we should probably abort/retry or something */
}
if (pc->stat != 0) {
......@@ -1573,20 +1573,9 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive)
{
struct packet_command pc; /* packet_command_t pc; */
struct request *rq = HWGROUP(drive)->rq;
unsigned nframes, frame;
nframes = rq->nr_sectors >> 2;
frame = rq->sector >> 2;
memcpy(pc.c, rq->cmd, sizeof(pc.c));
#if 0 /* the immediate bit */
pc.c[1] = 1 << 3;
#endif
pc.timeout = 2 * WAIT_CMD;
return cdrom_transfer_packet_command(drive, &pc, cdrom_write_intr);
return cdrom_transfer_packet_command(drive, rq->cmd, 2 * WAIT_CMD, cdrom_write_intr);
}
static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
......@@ -1620,34 +1609,13 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont);
}
/*
* just wrap this around cdrom_do_packet_command
*/
static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
{
struct packet_command pc;
ide_startstop_t startstop;
memset(&pc, 0, sizeof(pc));
memcpy(pc.c, rq->cmd, sizeof(pc.c));
pc.quiet = 1;
pc.timeout = 60 * HZ;
rq->special = (char *) &pc;
startstop = cdrom_do_packet_command(drive);
if (pc.stat)
rq->errors++;
return startstop;
}
#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
/****************************************************************************
* cdrom driver request routine.
*/
static ide_startstop_t
ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block)
ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, unsigned long block)
{
ide_startstop_t action;
struct cdrom_info *info = drive->driver_data;
......@@ -1679,18 +1647,31 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block)
} else if (rq->flags & (REQ_PC | REQ_SENSE)) {
return cdrom_do_packet_command(drive);
} else if (rq->flags & REQ_SPECIAL) {
/*
* FIXME: Kill REQ_SEPCIAL and replace it will command commands
* queued at the request queue instead as suggested (abd
* rightly so) by Linus.
* FIXME: Kill REQ_SEPCIAL and replace it with commands queued
* at the request queue instead as suggested by Linus.
*
* right now this can only be a reset...
*/
cdrom_end_request(drive, 1); return ide_stopped;
cdrom_end_request(drive, 1);
return ide_stopped;
} else if (rq->flags & REQ_BLOCK_PC) {
return cdrom_do_block_pc(drive, rq);
struct packet_command pc;
ide_startstop_t startstop;
memset(&pc, 0, sizeof(pc));
pc.quiet = 1;
pc.timeout = 60 * HZ;
/* FIXME --mdcki */
rq->special = (char *) &pc;
startstop = cdrom_do_packet_command(drive);
if (pc.stat)
++rq->errors;
return startstop;
}
blk_dump_rq_flags(rq, "ide-cd bad flags");
......@@ -1755,6 +1736,7 @@ int msf_to_lba (byte m, byte s, byte f)
static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
{
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *cdi = &info->devinfo;
......@@ -1762,16 +1744,16 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
memset(&pc, 0, sizeof(pc));
pc.sense = sense;
pc.c[0] = GPCMD_TEST_UNIT_READY;
cmd[0] = GPCMD_TEST_UNIT_READY;
#if ! STANDARD_ATAPI
#if !STANDARD_ATAPI
/* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to
switch CDs instead of supporting the LOAD_UNLOAD opcode */
pc.c[7] = cdi->sanyo_slot % 3;
#endif /* not STANDARD_ATAPI */
cmd[7] = cdi->sanyo_slot % 3;
#endif
return cdrom_queue_packet_command(drive, &pc);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
......@@ -1779,22 +1761,20 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
static int
cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense)
{
struct request_sense my_sense;
struct packet_command pc;
int stat;
if (sense == NULL)
sense = &my_sense;
/* If the drive cannot lock the door, just pretend. */
if (CDROM_CONFIG_FLAGS(drive)->no_doorlock) {
stat = 0;
} else {
unsigned char cmd[CDROM_PACKET_SIZE];
memset(&pc, 0, sizeof(pc));
pc.sense = sense;
pc.c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
pc.c[4] = lockflag ? 1 : 0;
stat = cdrom_queue_packet_command (drive, &pc);
cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
cmd[4] = lockflag ? 1 : 0;
stat = cdrom_queue_packet_command(drive, cmd, &pc);
}
/* If we got an illegal field error, the drive
......@@ -1825,6 +1805,7 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag,
struct request_sense *sense)
{
struct packet_command pc;
unsigned char cmd[CDROM_PACKET_SIZE];
if (CDROM_CONFIG_FLAGS(drive)->no_eject && !ejectflag)
return -EDRIVE_CANT_DO_THIS;
......@@ -1836,9 +1817,9 @@ static int cdrom_eject(ide_drive_t *drive, int ejectflag,
memset(&pc, 0, sizeof (pc));
pc.sense = sense;
pc.c[0] = GPCMD_START_STOP_UNIT;
pc.c[4] = 0x02 + (ejectflag != 0);
return cdrom_queue_packet_command (drive, &pc);
cmd[0] = GPCMD_START_STOP_UNIT;
cmd[4] = 0x02 + (ejectflag != 0);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
......@@ -1850,16 +1831,16 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
} capbuf;
int stat;
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
memset(&pc, 0, sizeof(pc));
pc.sense = sense;
pc.c[0] = GPCMD_READ_CDVD_CAPACITY;
cmd[0] = GPCMD_READ_CDVD_CAPACITY;
pc.buffer = (char *)&capbuf;
pc.buflen = sizeof(capbuf);
stat = cdrom_queue_packet_command(drive, &pc);
stat = cdrom_queue_packet_command(drive, cmd, &pc);
if (stat == 0)
*capacity = 1 + be32_to_cpu(capbuf.lba);
......@@ -1870,6 +1851,7 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
int format, char *buf, int buflen,
struct request_sense *sense)
{
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
memset(&pc, 0, sizeof(pc));
......@@ -1878,16 +1860,16 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
pc.buffer = buf;
pc.buflen = buflen;
pc.quiet = 1;
pc.c[0] = GPCMD_READ_TOC_PMA_ATIP;
pc.c[6] = trackno;
pc.c[7] = (buflen >> 8);
pc.c[8] = (buflen & 0xff);
pc.c[9] = (format << 6);
cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
if (msf_flag)
pc.c[1] = 2;
cmd[1] = 2;
cmd[6] = trackno;
cmd[7] = (buflen >> 8);
cmd[8] = (buflen & 0xff);
cmd[9] = (format << 6);
return cdrom_queue_packet_command (drive, &pc);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
......@@ -1916,7 +1898,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
/* Check to see if the existing data is still valid.
If it is, just return. */
(void) cdrom_check_status(drive, sense);
cdrom_check_status(drive, sense);
if (CDROM_STATE_FLAGS(drive)->toc_valid)
return 0;
......@@ -2049,6 +2031,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
int buflen, struct request_sense *sense)
{
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
memset(&pc, 0, sizeof(pc));
......@@ -2056,13 +2039,14 @@ static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
pc.buffer = buf;
pc.buflen = buflen;
pc.c[0] = GPCMD_READ_SUBCHANNEL;
pc.c[1] = 2; /* MSF addressing */
pc.c[2] = 0x40; /* request subQ data */
pc.c[3] = format;
pc.c[7] = (buflen >> 8);
pc.c[8] = (buflen & 0xff);
return cdrom_queue_packet_command(drive, &pc);
cmd[0] = GPCMD_READ_SUBCHANNEL;
cmd[1] = 2; /* MSF addressing */
cmd[2] = 0x40; /* request subQ data */
cmd[3] = format;
cmd[7] = (buflen >> 8);
cmd[8] = (buflen & 0xff);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
/* ATAPI cdrom drives are free to select the speed you request or any slower
......@@ -2070,6 +2054,7 @@ static int cdrom_read_subchannel(ide_drive_t *drive, int format, char *buf,
static int cdrom_select_speed(ide_drive_t *drive, int speed,
struct request_sense *sense)
{
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
memset(&pc, 0, sizeof(pc));
pc.sense = sense;
......@@ -2079,36 +2064,37 @@ static int cdrom_select_speed(ide_drive_t *drive, int speed,
else
speed *= 177; /* Nx to kbytes/s */
pc.c[0] = GPCMD_SET_SPEED;
cmd[0] = GPCMD_SET_SPEED;
/* Read Drive speed in kbytes/second MSB */
pc.c[2] = (speed >> 8) & 0xff;
cmd[2] = (speed >> 8) & 0xff;
/* Read Drive speed in kbytes/second LSB */
pc.c[3] = speed & 0xff;
cmd[3] = speed & 0xff;
if (CDROM_CONFIG_FLAGS(drive)->cd_r ||
CDROM_CONFIG_FLAGS(drive)->cd_rw ||
CDROM_CONFIG_FLAGS(drive)->dvd_r) {
/* Write Drive speed in kbytes/second MSB */
pc.c[4] = (speed >> 8) & 0xff;
cmd[4] = (speed >> 8) & 0xff;
/* Write Drive speed in kbytes/second LSB */
pc.c[5] = speed & 0xff;
cmd[5] = speed & 0xff;
}
return cdrom_queue_packet_command(drive, &pc);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
static int cdrom_play_audio(ide_drive_t *drive, int lba_start, int lba_end)
{
struct request_sense sense;
unsigned char cmd[CDROM_PACKET_SIZE];
struct packet_command pc;
memset(&pc, 0, sizeof (pc));
pc.sense = &sense;
pc.c[0] = GPCMD_PLAY_AUDIO_MSF;
lba_to_msf(lba_start, &pc.c[3], &pc.c[4], &pc.c[5]);
lba_to_msf(lba_end-1, &pc.c[6], &pc.c[7], &pc.c[8]);
cmd[0] = GPCMD_PLAY_AUDIO_MSF;
lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]);
lba_to_msf(lba_end-1, &cmd[6], &cmd[7], &cmd[8]);
return cdrom_queue_packet_command(drive, &pc);
return cdrom_queue_packet_command(drive, cmd, &pc);
}
static int cdrom_get_toc_entry(ide_drive_t *drive, int track,
......@@ -2152,15 +2138,15 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
layer. the packet must be complete, as we do not
touch it at all. */
memset(&pc, 0, sizeof(pc));
memcpy(pc.c, cgc->cmd, CDROM_PACKET_SIZE);
pc.buffer = cgc->buffer;
pc.buflen = cgc->buflen;
pc.quiet = cgc->quiet;
pc.timeout = cgc->timeout;
pc.sense = cgc->sense;
cgc->stat = cdrom_queue_packet_command(drive, &pc);
cgc->stat = cdrom_queue_packet_command(drive, cgc->cmd, &pc);
if (!cgc->stat)
cgc->buflen -= pc.buflen;
return cgc->stat;
}
......@@ -2214,7 +2200,6 @@ int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi,
static
int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
unsigned int cmd, void *arg)
{
ide_drive_t *drive = (ide_drive_t*) cdi->handle;
struct cdrom_info *info = drive->driver_data;
......@@ -2306,31 +2291,34 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
* lock it again.
*/
if (CDROM_STATE_FLAGS(drive)->door_locked)
(void) cdrom_lockdoor(drive, 1, &sense);
cdrom_lockdoor(drive, 1, &sense);
return ret;
}
static
int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
int ide_cdrom_tray_move(struct cdrom_device_info *cdi, int position)
{
ide_drive_t *drive = (ide_drive_t*) cdi->handle;
struct request_sense sense;
if (position) {
int stat = cdrom_lockdoor(drive, 0, &sense);
if (stat) return stat;
if (stat)
return stat;
}
return cdrom_eject(drive, !position, &sense);
}
static
int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
int ide_cdrom_lock_door(struct cdrom_device_info *cdi, int lock)
{
ide_drive_t *drive = (ide_drive_t*) cdi->handle;
return cdrom_lockdoor(drive, lock, NULL);
struct request_sense sense;
return cdrom_lockdoor(drive, lock, &sense);
}
static
......@@ -2435,7 +2423,7 @@ int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi,
int retval;
if (slot_nr == CDSL_CURRENT) {
(void) cdrom_check_status(drive, NULL);
cdrom_check_status(drive, NULL);
retval = CDROM_STATE_FLAGS (drive)->media_changed;
CDROM_STATE_FLAGS (drive)->media_changed = 0;
return retval;
......@@ -2678,7 +2666,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
static void ide_cdrom_add_settings(ide_drive_t *drive)
{
ide_add_setting(drive, "dsc_overlap", SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
ide_add_setting(drive, "dsc_overlap",
SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
}
static
......@@ -2763,16 +2752,12 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 1;
CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
}
else if (strcmp (drive->id->model, "V006E0DS") == 0 &&
} else if (strcmp (drive->id->model, "V006E0DS") == 0 &&
drive->id->fw_rev[4] == '1' &&
drive->id->fw_rev[6] <= '2') {
/* Vertos 600 ESD. */
CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1;
}
else if (strcmp (drive->id->model,
} else if (strcmp (drive->id->model,
"NEC CD-ROM DRIVE:260") == 0 &&
strncmp (drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */
/* Old NEC260 (not R).
......@@ -2782,9 +2767,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
CDROM_CONFIG_FLAGS (drive)->nec260 = 1;
}
else if (strcmp (drive->id->model, "WEARNES CDD-120") == 0 &&
} else if (strcmp (drive->id->model, "WEARNES CDD-120") == 0 &&
strncmp (drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */
/* Wearnes */
CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
......@@ -2989,7 +2972,7 @@ int ide_cdrom_init(void)
kfree (info);
continue;
}
memset (info, 0, sizeof (struct cdrom_info));
memset(info, 0, sizeof (struct cdrom_info));
drive->driver_data = info;
MOD_INC_USE_COUNT;
......
......@@ -15,7 +15,7 @@
memory, though. */
#ifndef VERBOSE_IDE_CD_ERRORS
#define VERBOSE_IDE_CD_ERRORS 1
# define VERBOSE_IDE_CD_ERRORS 1
#endif
......@@ -24,7 +24,7 @@
this will give you a slightly smaller kernel. */
#ifndef STANDARD_ATAPI
#define STANDARD_ATAPI 0
# define STANDARD_ATAPI 0
#endif
......@@ -32,14 +32,14 @@
This is apparently needed for supermount. */
#ifndef NO_DOOR_LOCKING
#define NO_DOOR_LOCKING 0
# define NO_DOOR_LOCKING 0
#endif
/************************************************************************/
#define SECTOR_BITS 9
#ifndef SECTOR_SIZE
#define SECTOR_SIZE (1 << SECTOR_BITS)
# define SECTOR_SIZE (1 << SECTOR_BITS)
#endif
#define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS)
#define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32)
......@@ -50,12 +50,6 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
/* special command codes for strategy routine. */
#define PACKET_COMMAND 4315
#define REQUEST_SENSE_COMMAND 4316
#define RESET_DRIVE_COMMAND 4317
/* Configuration flags. These describe the capabilities of the drive.
They generally do not change after initialization, unless we learn
more about the drive from stuff failing. */
......@@ -90,7 +84,6 @@ struct ide_cd_config_flags {
};
#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags))
/* State flags. These give information about the current state of the
drive, and will change during normal operation. */
struct ide_cd_state_flags {
......@@ -111,24 +104,23 @@ struct packet_command {
int quiet;
int timeout;
struct request_sense *sense;
unsigned char c[12];
};
/* Structure of a MSF cdrom address. */
struct atapi_msf {
byte reserved;
byte minute;
byte second;
byte frame;
};
u8 __reserved;
u8 minute;
u8 second;
u8 frame;
} __attribute__((packed));
/* Space to hold the disk TOC. */
#define MAX_TRACKS 99
struct atapi_toc_header {
unsigned short toc_length;
byte first_track;
byte last_track;
};
u16 toc_length;
u8 first_track;
u8 last_track;
} __attribute__((packed));
struct atapi_toc_entry {
byte reserved1;
......@@ -162,17 +154,17 @@ struct atapi_toc {
/* This structure is annoyingly close to, but not identical with,
the cdrom_subchnl structure from cdrom.h. */
struct atapi_cdrom_subchnl {
u_char acdsc_reserved;
u_char acdsc_audiostatus;
u_short acdsc_length;
u_char acdsc_format;
u8 acdsc_reserved;
u8 acdsc_audiostatus;
u16 acdsc_length;
u8 acdsc_format;
#if defined(__BIG_ENDIAN_BITFIELD)
u_char acdsc_ctrl: 4;
u_char acdsc_adr: 4;
u8 acdsc_ctrl: 4;
u8 acdsc_adr: 4;
#elif defined(__LITTLE_ENDIAN_BITFIELD)
u_char acdsc_adr: 4;
u_char acdsc_ctrl: 4;
u8 acdsc_adr: 4;
u8 acdsc_ctrl: 4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
......
......@@ -980,7 +980,7 @@ int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
/* FIXME: Do we really have to zero out the buffer?
*/
memset(argbuf, 0, 4 + SECTOR_WORDS * 4 * vals[3]);
memset(argbuf, 4, SECTOR_WORDS * 4 * vals[3]);
ide_init_drive_cmd(&rq);
rq.buffer = argbuf;
memcpy(argbuf, vals, 4);
......
......@@ -2701,7 +2701,11 @@ static int ide_ioctl (struct inode *inode, struct file *file,
void ide_teardown_commandlist(ide_drive_t *drive)
{
struct pci_dev *pdev= drive->channel->pci_dev;
#ifdef CONFIG_BLK_DEV_IDEPCI
struct pci_dev *pdev = drive->channel->pci_dev;
#else
struct pci_dev *pdev = NULL;
#endif
struct list_head *entry;
list_for_each(entry, &drive->free_req) {
......@@ -2716,7 +2720,11 @@ void ide_teardown_commandlist(ide_drive_t *drive)
int ide_build_commandlist(ide_drive_t *drive)
{
struct pci_dev *pdev= drive->channel->pci_dev;
#ifdef CONFIG_BLK_DEV_IDEPCI
struct pci_dev *pdev = drive->channel->pci_dev;
#else
struct pci_dev *pdev = NULL;
#endif
struct ata_request *ar;
ide_tag_info_t *tcq;
int i, err;
......@@ -2764,9 +2772,9 @@ int ide_build_commandlist(ide_drive_t *drive)
if (i) {
drive->queue_depth = i;
if (i >= 1) {
drive->using_tcq = 1;
drive->tcq->queued = 0;
drive->tcq->active_tag = -1;
return 0;
}
......
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