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