patch-2.4.21 linux-2.4.21/drivers/ide/ide-cd.c
Next file: linux-2.4.21/drivers/ide/ide-cd.h
Previous file: linux-2.4.21/drivers/ide/ide-adma.c
Back to the patch index
Back to the overall index
- Lines: 1578
- Date:
2003-06-13 07:51:33.000000000 -0700
- Orig file:
linux-2.4.20/drivers/ide/ide-cd.c
- Orig date:
2002-11-28 15:53:13.000000000 -0800
diff -urN linux-2.4.20/drivers/ide/ide-cd.c linux-2.4.21/drivers/ide/ide-cd.c
@@ -294,7 +294,7 @@
*
*************************************************************************/
-#define IDECD_VERSION "4.59"
+#define IDECD_VERSION "4.59-ac1"
#include <linux/config.h>
#include <linux/module.h>
@@ -540,7 +540,141 @@
}
-static void cdrom_end_request (int uptodate, ide_drive_t *drive)
+/*
+ * This is our end_request replacement function.
+ */
+static int ide_cdrom_end_request (ide_drive_t *drive, int uptodate)
+{
+ struct request *rq;
+ unsigned long flags;
+ int ret = 1;
+
+ spin_lock_irqsave(&io_request_lock, flags);
+ rq = HWGROUP(drive)->rq;
+
+ /*
+ * decide whether to reenable DMA -- 3 is a random magic for now,
+ * if we DMA timeout more than 3 times, just stay in PIO
+ */
+ if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) {
+ drive->state = 0;
+ HWGROUP(drive)->hwif->ide_dma_on(drive);
+ }
+
+ if (!end_that_request_first(rq, uptodate, drive->name)) {
+ add_blkdev_randomness(MAJOR(rq->rq_dev));
+ blkdev_dequeue_request(rq);
+ HWGROUP(drive)->rq = NULL;
+ end_that_request_last(rq);
+ ret = 0;
+ }
+ spin_unlock_irqrestore(&io_request_lock, flags);
+ return ret;
+}
+
+/*
+ * Error reporting, in human readable form (luxurious, but a memory hog).
+ */
+byte ide_cdrom_dump_status (ide_drive_t *drive, const char *msg, byte stat)
+{
+ unsigned long flags;
+
+ atapi_status_t status;
+ atapi_error_t error;
+
+ status.all = stat;
+ local_irq_set(flags);
+ printk("%s: %s: status=0x%02x", drive->name, msg, stat);
+#if FANCY_STATUS_DUMPS
+ printk(" { ");
+ if (status.b.bsy)
+ printk("Busy ");
+ else {
+ if (status.b.drdy) printk("DriveReady ");
+ if (status.b.df) printk("DeviceFault ");
+ if (status.b.dsc) printk("SeekComplete ");
+ if (status.b.drq) printk("DataRequest ");
+ if (status.b.corr) printk("CorrectedError ");
+ if (status.b.idx) printk("Index ");
+ if (status.b.check) printk("Error ");
+ }
+ printk("}");
+#endif /* FANCY_STATUS_DUMPS */
+ printk("\n");
+ if ((status.all & (status.b.bsy|status.b.check)) == status.b.check) {
+ error.all = HWIF(drive)->INB(IDE_ERROR_REG);
+ printk("%s: %s: error=0x%02x", drive->name, msg, error.all);
+#if FANCY_STATUS_DUMPS
+ if (error.b.ili) printk("IllegalLengthIndication ");
+ if (error.b.eom) printk("EndOfMedia ");
+ if (error.b.abrt) printk("Aborted Command ");
+ if (error.b.mcr) printk("MediaChangeRequested ");
+ if (error.b.sense_key) printk("LastFailedSense 0x%02x ",
+ error.b.sense_key);
+#endif /* FANCY_STATUS_DUMPS */
+ printk("\n");
+ }
+ local_irq_restore(flags);
+ return error.all;
+}
+
+/*
+ * ide_error() takes action based on the error returned by the drive.
+ */
+ide_startstop_t ide_cdrom_error (ide_drive_t *drive, const char *msg, byte stat)
+{
+ struct request *rq;
+ byte err;
+
+ err = ide_cdrom_dump_status(drive, msg, stat);
+ if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
+ return ide_stopped;
+ /* retry only "normal" I/O: */
+ if (rq->cmd == IDE_DRIVE_CMD || rq->cmd == IDE_DRIVE_TASK) {
+ rq->errors = 1;
+ ide_end_drive_cmd(drive, stat, err);
+ return ide_stopped;
+ }
+
+ if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) {
+ /* other bits are useless when BUSY */
+ rq->errors |= ERROR_RESET;
+ } else {
+ /* add decoding error stuff */
+ }
+ if (HWIF(drive)->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
+ /* force an abort */
+ HWIF(drive)->OUTB(WIN_IDLEIMMEDIATE,IDE_COMMAND_REG);
+ if (rq->errors >= ERROR_MAX) {
+ DRIVER(drive)->end_request(drive, 0);
+ } else {
+ if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
+ ++rq->errors;
+ return ide_do_reset(drive);
+ }
+ ++rq->errors;
+ }
+ return ide_stopped;
+}
+
+ide_startstop_t ide_cdrom_abort (ide_drive_t *drive, const char *msg)
+{
+ struct request *rq;
+
+ if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
+ return ide_stopped;
+ /* retry only "normal" I/O: */
+ if (rq->cmd == IDE_DRIVE_CMD || rq->cmd == IDE_DRIVE_TASK) {
+ rq->errors = 1;
+ ide_end_drive_cmd(drive, BUSY_STAT, 0);
+ return ide_stopped;
+ }
+ rq->errors |= ERROR_RESET;
+ DRIVER(drive)->end_request(drive, 0);
+ return ide_stopped;
+}
+
+static void cdrom_end_request (ide_drive_t *drive, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
@@ -550,11 +684,10 @@
(struct packet_command *) pc->sense,
(struct request_sense *) (pc->buffer - pc->c[4]));
}
- if (rq->cmd == READ || rq->cmd == WRITE)
- if (!rq->current_nr_sectors)
- uptodate = 1;
+ if (blk_fs_request(rq) && !rq->current_nr_sectors)
+ uptodate = 1;
- ide_end_request (uptodate, HWGROUP(drive));
+ ide_cdrom_end_request(drive, uptodate);
}
@@ -568,14 +701,13 @@
struct packet_command *pc;
/* Check for errors. */
- stat = GET_STAT();
- *stat_ret = stat;
+ *stat_ret = stat = HWIF(drive)->INB(IDE_STATUS_REG);
if (OK_STAT (stat, good_stat, BAD_R_STAT))
return 0;
/* Get the IDE error register. */
- err = GET_ERR();
+ err = HWIF(drive)->INB(IDE_ERROR_REG);
sense_key = err >> 4;
if (rq == NULL) {
@@ -591,8 +723,8 @@
pc = (struct packet_command *) rq->buffer;
pc->stat = 1;
- cdrom_end_request (1, drive);
- *startstop = ide_error (drive, "request sense failure", stat);
+ cdrom_end_request(drive, 1);
+ *startstop = DRIVER(drive)->error(drive, "request sense failure", stat);
return 1;
} else if (rq->cmd == PACKET_COMMAND) {
@@ -628,11 +760,11 @@
}
pc->stat = 1;
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
if ((stat & ERR_STAT) != 0)
cdrom_queue_request_sense(drive, wait, pc->sense, pc);
- } else {
+ } else if (blk_fs_request(rq)) {
/* Handle errors from READ and WRITE requests. */
if (sense_key == NOT_READY) {
@@ -641,7 +773,7 @@
/* Fail the request. */
printk ("%s: tray open\n", drive->name);
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
} else if (sense_key == UNIT_ATTENTION) {
/* Media change. */
cdrom_saw_media_change (drive);
@@ -650,21 +782,26 @@
But be sure to give up if we've retried
too many times. */
if (++rq->errors > ERROR_MAX)
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
} else if (sense_key == ILLEGAL_REQUEST ||
sense_key == DATA_PROTECT) {
/* No point in retrying after an illegal
request or data protect error.*/
ide_dump_status (drive, "command error", stat);
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
} else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler
for other errors. */
- *startstop = ide_error (drive, "cdrom_decode_status", stat);
+ *startstop = DRIVER(drive)->error(drive, "cdrom_decode_status", stat);
return 1;
+ } else if (sense_key == MEDIUM_ERROR) {
+ /* No point in re-trying a zillion times on a bad
+ * sector... If we got here the error is not correctable */
+ ide_dump_status (drive, "media error (bad sector)", stat);
+ cdrom_end_request(drive, 0);
} else if ((++rq->errors > ERROR_MAX)) {
/* We've racked up too many retries. Abort. */
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
}
/* If we got a CHECK_CONDITION status,
@@ -723,33 +860,32 @@
if (info->dma) {
if (info->cmd == READ) {
- info->dma = !HWIF(drive)->dmaproc(ide_dma_read, drive);
+ info->dma = !HWIF(drive)->ide_dma_read(drive);
} else if (info->cmd == WRITE) {
- info->dma = !HWIF(drive)->dmaproc(ide_dma_write, drive);
+ info->dma = !HWIF(drive)->ide_dma_write(drive);
} else {
printk("ide-cd: DMA set, but not allowed\n");
}
}
/* Set up the controller registers. */
- OUT_BYTE (info->dma, IDE_FEATURE_REG);
- OUT_BYTE (0, IDE_NSECTOR_REG);
- OUT_BYTE (0, IDE_SECTOR_REG);
+ /* FIXME: for Virtual DMA we must check harder */
+ HWIF(drive)->OUTB(info->dma, IDE_FEATURE_REG);
+ HWIF(drive)->OUTB(0, IDE_IREASON_REG);
+ HWIF(drive)->OUTB(0, IDE_SECTOR_REG);
- OUT_BYTE (xferlen & 0xff, IDE_LCYL_REG);
- OUT_BYTE (xferlen >> 8 , IDE_HCYL_REG);
+ HWIF(drive)->OUTB(xferlen & 0xff, IDE_BCOUNTL_REG);
+ HWIF(drive)->OUTB(xferlen >> 8 , IDE_BCOUNTH_REG);
if (IDE_CONTROL_REG)
- OUT_BYTE (drive->ctl, IDE_CONTROL_REG);
+ HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
- if (info->dma)
- (void) (HWIF(drive)->dmaproc(ide_dma_begin, drive));
-
if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
- ide_set_handler (drive, handler, WAIT_CMD, cdrom_timer_expiry);
- OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* packet command */
+ /* packet command */
+ ide_execute_command(drive, WIN_PACKETCMD, handler, WAIT_CMD, cdrom_timer_expiry);
return ide_started;
} else {
- OUT_BYTE (WIN_PACKETCMD, IDE_COMMAND_REG); /* packet command */
+ /* packet command */
+ HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
return (*handler) (drive);
}
}
@@ -770,27 +906,34 @@
unsigned char *cmd_buf = pc->c;
int cmd_len = sizeof(pc->c);
unsigned int timeout = pc->timeout;
+ struct cdrom_info *info = drive->driver_data;
ide_startstop_t startstop;
- if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
+ if (CDROM_CONFIG_FLAGS(drive)->drq_interrupt) {
/* Here we should have been called after receiving an interrupt
from the device. DRQ should how be set. */
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. */
- 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);
+ HWIF(drive)->atapi_output_bytes(drive, cmd_buf, cmd_len);
+
+ /* Start the DMA if need be */
+ if (info->dma)
+ (void) HWIF(drive)->ide_dma_begin(drive);
+
return ide_started;
}
@@ -828,7 +971,7 @@
/* Read the data into the buffer. */
dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE;
while (sectors_to_buffer > 0) {
- atapi_input_bytes (drive, dest, SECTOR_SIZE);
+ HWIF(drive)->atapi_input_bytes(drive, dest, SECTOR_SIZE);
--sectors_to_buffer;
--sectors_to_transfer;
++info->nsectors_buffered;
@@ -838,7 +981,7 @@
/* Throw away any remaining data. */
while (sectors_to_transfer > 0) {
char dum[SECTOR_SIZE];
- atapi_input_bytes (drive, dum, sizeof (dum));
+ HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum));
--sectors_to_transfer;
}
}
@@ -864,14 +1007,14 @@
and quit this request. */
while (len > 0) {
int dum = 0;
- atapi_output_bytes (drive, &dum, sizeof (dum));
+ HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof (dum));
len -= sizeof (dum);
}
} else if (ireason == 1) {
/* Some drives (ASUS) seem to tell us that status
* info is available. just get it and ignore.
*/
- GET_STAT();
+ (void) HWIF(drive)->INB(IDE_STATUS_REG);
return 0;
} else {
/* Drive wants a command packet, or invalid ireason... */
@@ -879,7 +1022,7 @@
drive->name, ireason);
}
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
return -1;
}
@@ -891,6 +1034,7 @@
int stat;
int ireason, len, sectors_to_transfer, nskip;
struct cdrom_info *info = drive->driver_data;
+ u8 lowcyl = 0, highcyl = 0;
int i, dma = info->dma, dma_error = 0;
ide_startstop_t startstop;
@@ -899,8 +1043,8 @@
/* Check for errors. */
if (dma) {
info->dma = 0;
- if ((dma_error = HWIF(drive)->dmaproc(ide_dma_end, drive)))
- HWIF(drive)->dmaproc(ide_dma_off, drive);
+ if ((dma_error = HWIF(drive)->ide_dma_end(drive)))
+ HWIF(drive)->ide_dma_off(drive);
}
if (cdrom_decode_status (&startstop, drive, 0, &stat))
@@ -910,16 +1054,19 @@
if (!dma_error) {
for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors;
- ide_end_request(1, HWGROUP(drive));
+ ide_cdrom_end_request(drive, 1);
}
return ide_stopped;
} else
- return ide_error (drive, "dma error", stat);
+ return DRIVER(drive)->error(drive, "dma error", stat);
}
/* Read the interrupt reason and the transfer length. */
- ireason = IN_BYTE (IDE_NSECTOR_REG);
- len = IN_BYTE (IDE_LCYL_REG) + 256 * IN_BYTE (IDE_HCYL_REG);
+ ireason = HWIF(drive)->INB(IDE_IREASON_REG);
+ lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG);
+ highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG);
+
+ len = lowcyl + (256 * highcyl);
/* If DRQ is clear, the command has completed. */
if ((stat & DRQ_STAT) == 0) {
@@ -928,9 +1075,9 @@
if (rq->current_nr_sectors > 0) {
printk ("%s: cdrom_read_intr: data underrun (%ld blocks)\n",
drive->name, rq->current_nr_sectors);
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
} else
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
return ide_stopped;
}
@@ -944,13 +1091,13 @@
if ((len % SECTOR_SIZE) != 0) {
printk ("%s: cdrom_read_intr: Bad transfer size %d\n",
drive->name, len);
- if (CDROM_CONFIG_FLAGS (drive)->limit_nframes)
+ if (CDROM_CONFIG_FLAGS(drive)->limit_nframes)
printk (" This drive is not supported by this version of the driver\n");
else {
printk (" Trying to limit transfer sizes\n");
- CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
+ CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1;
}
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
return ide_stopped;
}
@@ -965,7 +1112,7 @@
while (nskip > 0) {
/* We need to throw away a sector. */
char dum[SECTOR_SIZE];
- atapi_input_bytes (drive, dum, sizeof (dum));
+ HWIF(drive)->atapi_input_bytes(drive, dum, sizeof (dum));
--rq->current_nr_sectors;
--nskip;
@@ -979,7 +1126,7 @@
/* If we've filled the present buffer but there's another
chained buffer after it, move on. */
if (rq->current_nr_sectors == 0 && rq->nr_sectors)
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
/* If the buffers are full, cache the rest of the data in our
internal buffer. */
@@ -996,7 +1143,7 @@
/* Read this_transfer sectors
into the current buffer. */
while (this_transfer > 0) {
- atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE);
+ HWIF(drive)->atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE);
rq->buffer += SECTOR_SIZE;
--rq->nr_sectors;
--rq->current_nr_sectors;
@@ -1007,8 +1154,7 @@
}
}
- /* Done moving data!
- Wait for another interrupt. */
+ /* Done moving data! Wait for another interrupt. */
ide_set_handler(drive, &cdrom_read_intr, WAIT_CMD, NULL);
return ide_started;
}
@@ -1031,7 +1177,7 @@
rq->sector >= info->sector_buffered &&
rq->sector < info->sector_buffered + info->nsectors_buffered) {
if (rq->current_nr_sectors == 0)
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
memcpy (rq->buffer,
info->buffer +
@@ -1046,13 +1192,13 @@
/* If we've satisfied the current request,
terminate it successfully. */
if (rq->nr_sectors == 0) {
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
return -1;
}
/* Move on to the next buffer if needed. */
if (rq->current_nr_sectors == 0)
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
/* If this condition does not hold, then the kluge i use to
represent the number of sectors to skip at the start of a transfer
@@ -1060,9 +1206,9 @@
paranoid and check. */
if (rq->current_nr_sectors < (rq->bh->b_size >> SECTOR_BITS) &&
(rq->sector % SECTORS_PER_FRAME) != 0) {
- printk ("%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
+ printk("%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
drive->name, rq->sector);
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
return -1;
}
@@ -1101,7 +1247,7 @@
(rq->sector % CD_FRAMESIZE != 0)) {
printk ("%s: cdrom_start_read_continuation: buffer botch (%lu)\n",
drive->name, rq->current_nr_sectors);
- cdrom_end_request (0, drive);
+ cdrom_end_request(drive, 0);
return ide_stopped;
}
sector -= nskip;
@@ -1147,7 +1293,7 @@
return startstop;
CDROM_CONFIG_FLAGS(drive)->seeking = 1;
- if (retry && jiffies - info->start_seek > IDECD_SEEK_TIMER) {
+ if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) {
if (--retry == 0) {
/*
* this condition is far too common, to bother
@@ -1189,7 +1335,7 @@
info->dma = 0;
info->cmd = 0;
info->start_seek = jiffies;
- return cdrom_start_packet_command (drive, 0, cdrom_start_seek_continuation);
+ return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
}
static inline int cdrom_merge_requests(struct request *rq, struct request *nxt)
@@ -1263,7 +1409,7 @@
{
struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
- int minor = MINOR (rq->rq_dev);
+ int minor = MINOR(rq->rq_dev);
/* If the request is relative to a partition, fix it up to refer to the
absolute address. */
@@ -1313,14 +1459,18 @@
struct request *rq = HWGROUP(drive)->rq;
struct packet_command *pc = (struct packet_command *)rq->buffer;
ide_startstop_t startstop;
+ u8 lowcyl = 0, highcyl = 0;
/* Check for errors. */
- if (cdrom_decode_status (&startstop, drive, 0, &stat))
+ if (cdrom_decode_status(&startstop, drive, 0, &stat))
return startstop;
/* Read the interrupt reason and the transfer length. */
- ireason = IN_BYTE (IDE_NSECTOR_REG);
- len = IN_BYTE (IDE_LCYL_REG) + 256 * IN_BYTE (IDE_HCYL_REG);
+ ireason = HWIF(drive)->INB(IDE_IREASON_REG);
+ lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG);
+ highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG);
+
+ len = lowcyl + (256 * highcyl);
/* If DRQ is clear, the command has completed.
Complain if we still have data left to transfer. */
@@ -1337,7 +1487,7 @@
}
if (pc->buflen == 0)
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
else {
/* Comment this out, because this always happens
right after a reset occurs, and it is annoying to
@@ -1347,7 +1497,7 @@
drive->name, pc->buflen);
*/
pc->stat = 1;
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
}
return ide_stopped;
}
@@ -1359,14 +1509,14 @@
/* The drive wants to be written to. */
if ((ireason & 3) == 0) {
/* Transfer the data. */
- atapi_output_bytes (drive, pc->buffer, thislen);
+ HWIF(drive)->atapi_output_bytes(drive, pc->buffer, thislen);
/* If we haven't moved enough data to satisfy the drive,
add some padding. */
while (len > thislen) {
int dum = 0;
- atapi_output_bytes (drive, &dum, sizeof (dum));
- len -= sizeof (dum);
+ HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof(dum));
+ len -= sizeof(dum);
}
/* Keep count of how much data we've moved. */
@@ -1378,14 +1528,14 @@
else if ((ireason & 3) == 2) {
/* Transfer the data. */
- atapi_input_bytes (drive, pc->buffer, thislen);
+ HWIF(drive)->atapi_input_bytes(drive, pc->buffer, thislen);
/* If we haven't moved enough data to satisfy the drive,
add some padding. */
while (len > thislen) {
int dum = 0;
- atapi_input_bytes (drive, &dum, sizeof (dum));
- len -= sizeof (dum);
+ HWIF(drive)->atapi_input_bytes(drive, &dum, sizeof(dum));
+ len -= sizeof(dum);
}
/* Keep count of how much data we've moved. */
@@ -1399,7 +1549,7 @@
}
/* Now we wait for another interrupt. */
- ide_set_handler (drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
+ ide_set_handler(drive, &cdrom_pc_intr, WAIT_CMD, cdrom_timer_expiry);
return ide_started;
}
@@ -1430,7 +1580,7 @@
len = pc->buflen;
/* Start sending the command to the drive. */
- return cdrom_start_packet_command (drive, len, cdrom_do_pc_continuation);
+ return cdrom_start_packet_command(drive, len, cdrom_do_pc_continuation);
}
@@ -1462,7 +1612,7 @@
ide_init_drive_cmd (&req);
req.cmd = PACKET_COMMAND;
req.buffer = (char *)pc;
- ide_do_drive_cmd (drive, &req, ide_wait);
+ ide_do_drive_cmd(drive, &req, ide_wait);
/* FIXME: we should probably abort/retry or something
* in case of failure */
if (pc->stat != 0) {
@@ -1472,7 +1622,7 @@
struct request_sense *reqbuf = pc->sense;
if (reqbuf->sense_key == UNIT_ATTENTION)
- cdrom_saw_media_change (drive);
+ cdrom_saw_media_change(drive);
else if (reqbuf->sense_key == NOT_READY &&
reqbuf->asc == 4 && reqbuf->ascq != 4) {
/* The drive is in the process of loading
@@ -1513,7 +1663,7 @@
and quit this request. */
while (len > 0) {
int dum = 0;
- atapi_output_bytes(drive, &dum, sizeof(dum));
+ HWIF(drive)->atapi_output_bytes(drive, &dum, sizeof(dum));
len -= sizeof(dum);
}
} else {
@@ -1522,7 +1672,7 @@
drive->name, ireason);
}
- cdrom_end_request(0, drive);
+ cdrom_end_request(drive, 0);
return 1;
}
@@ -1531,6 +1681,7 @@
int stat, ireason, len, sectors_to_transfer, uptodate;
struct cdrom_info *info = drive->driver_data;
int i, dma_error = 0, dma = info->dma;
+ u8 lowcyl = 0, highcyl = 0;
ide_startstop_t startstop;
struct request *rq = HWGROUP(drive)->rq;
@@ -1538,9 +1689,9 @@
/* Check for errors. */
if (dma) {
info->dma = 0;
- if ((dma_error = HWIF(drive)->dmaproc(ide_dma_end, drive))) {
+ if ((dma_error = HWIF(drive)->ide_dma_end(drive))) {
printk("ide-cd: write dma error\n");
- HWIF(drive)->dmaproc(ide_dma_off, drive);
+ HWIF(drive)->ide_dma_off(drive);
}
}
@@ -1554,19 +1705,22 @@
*/
if (dma) {
if (dma_error)
- return ide_error(drive, "dma error", stat);
+ return DRIVER(drive)->error(drive, "dma error", stat);
rq = HWGROUP(drive)->rq;
for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors;
- ide_end_request(1, HWGROUP(drive));
+ ide_cdrom_end_request(drive, 1);
}
return ide_stopped;
}
/* Read the interrupt reason and the transfer length. */
- ireason = IN_BYTE(IDE_NSECTOR_REG);
- len = IN_BYTE(IDE_LCYL_REG) + 256 * IN_BYTE(IDE_HCYL_REG);
+ ireason = HWIF(drive)->INB(IDE_IREASON_REG);
+ lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG);
+ highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG);
+
+ len = lowcyl + (256 * highcyl);
/* If DRQ is clear, the command has completed. */
if ((stat & DRQ_STAT) == 0) {
@@ -1579,7 +1733,7 @@
drive->name, rq->current_nr_sectors);
uptodate = 0;
}
- cdrom_end_request(uptodate, drive);
+ cdrom_end_request(drive, uptodate);
return ide_stopped;
}
@@ -1607,7 +1761,7 @@
this_transfer = MIN(sectors_to_transfer,rq->current_nr_sectors);
while (this_transfer > 0) {
- atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE);
+ HWIF(drive)->atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE);
rq->buffer += SECTOR_SIZE;
--rq->nr_sectors;
--rq->current_nr_sectors;
@@ -1620,7 +1774,7 @@
* current buffer complete, move on
*/
if (rq->current_nr_sectors == 0 && rq->nr_sectors)
- cdrom_end_request (1, drive);
+ cdrom_end_request(drive, 1);
}
/* re-arm handler */
@@ -1662,7 +1816,7 @@
* writes *must* be 2kB frame aligned
*/
if ((rq->nr_sectors & 3) || (rq->sector & 3)) {
- cdrom_end_request(0, drive);
+ cdrom_end_request(drive, 0);
return ide_stopped;
}
@@ -1698,11 +1852,10 @@
case WRITE:
case READ: {
if (CDROM_CONFIG_FLAGS(drive)->seeking) {
- unsigned long elpased = jiffies - info->start_seek;
- int stat = GET_STAT();
+ int stat = HWIF(drive)->INB(IDE_STATUS_REG);
if ((stat & SEEK_STAT) != SEEK_STAT) {
- if (elpased < IDECD_SEEK_TIMEOUT) {
+ if (time_before(jiffies, info->start_seek + IDECD_SEEK_TIMEOUT)) {
ide_stall_queue(drive, IDECD_SEEK_TIMER);
return ide_stopped;
}
@@ -1711,9 +1864,9 @@
CDROM_CONFIG_FLAGS(drive)->seeking = 0;
}
if (IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap)
- action = cdrom_start_seek (drive, block);
+ action = cdrom_start_seek(drive, block);
else {
- if (rq->cmd == READ)
+ if (rq_data_dir(rq) == READ)
action = cdrom_start_read(drive, block);
else
action = cdrom_start_write(drive, rq);
@@ -1728,13 +1881,13 @@
}
case RESET_DRIVE_COMMAND: {
- cdrom_end_request(1, drive);
+ cdrom_end_request(drive, 1);
return ide_do_reset(drive);
}
default: {
printk("ide-cd: bad cmd %d\n", rq->cmd);
- cdrom_end_request(0, drive);
+ cdrom_end_request(drive, 0);
return ide_stopped;
}
}
@@ -1836,7 +1989,7 @@
pc.sense = sense;
pc.c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
pc.c[4] = lockflag ? 1 : 0;
- stat = cdrom_queue_packet_command (drive, &pc);
+ stat = cdrom_queue_packet_command(drive, &pc);
}
/* If we got an illegal field error, the drive
@@ -1846,7 +1999,7 @@
(sense->asc == 0x24 || sense->asc == 0x20)) {
printk ("%s: door locking not supported\n",
drive->name);
- CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
+ CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
stat = 0;
}
@@ -1855,7 +2008,7 @@
stat = 0;
if (stat == 0)
- CDROM_STATE_FLAGS (drive)->door_locked = lockflag;
+ CDROM_STATE_FLAGS(drive)->door_locked = lockflag;
return stat;
}
@@ -1880,7 +2033,7 @@
pc.c[0] = GPCMD_START_STOP_UNIT;
pc.c[4] = 0x02 + (ejectflag != 0);
- return cdrom_queue_packet_command (drive, &pc);
+ return cdrom_queue_packet_command(drive, &pc);
}
static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
@@ -1929,7 +2082,7 @@
if (msf_flag)
pc.c[1] = 2;
- return cdrom_queue_packet_command (drive, &pc);
+ return cdrom_queue_packet_command(drive, &pc);
}
@@ -1969,9 +2122,9 @@
if (stat) return stat;
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
- toc->hdr.first_track = bcd2bin (toc->hdr.first_track);
- toc->hdr.last_track = bcd2bin (toc->hdr.last_track);
+ if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {
+ toc->hdr.first_track = bcd2bin(toc->hdr.first_track);
+ toc->hdr.last_track = bcd2bin(toc->hdr.last_track);
}
#endif /* not STANDARD_ATAPI */
@@ -2009,7 +2162,7 @@
return stat;
}
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
+ if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {
toc->hdr.first_track = bin2bcd(CDROM_LEADOUT);
toc->hdr.last_track = bin2bcd(CDROM_LEADOUT);
} else
@@ -2026,18 +2179,18 @@
toc->hdr.toc_length = ntohs (toc->hdr.toc_length);
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd) {
- toc->hdr.first_track = bcd2bin (toc->hdr.first_track);
- toc->hdr.last_track = bcd2bin (toc->hdr.last_track);
+ if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {
+ toc->hdr.first_track = bcd2bin(toc->hdr.first_track);
+ toc->hdr.last_track = bcd2bin(toc->hdr.last_track);
}
#endif /* not STANDARD_ATAPI */
for (i=0; i<=ntracks; i++) {
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd) {
- if (CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd)
- toc->ent[i].track = bcd2bin (toc->ent[i].track);
- msf_from_bcd (&toc->ent[i].addr.msf);
+ if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) {
+ if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd)
+ toc->ent[i].track = bcd2bin(toc->ent[i].track);
+ msf_from_bcd(&toc->ent[i].addr.msf);
}
#endif /* not STANDARD_ATAPI */
toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute,
@@ -2059,7 +2212,7 @@
}
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd)
+ if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd)
msf_from_bcd (&ms_tmp.ent.addr.msf);
#endif /* not STANDARD_ATAPI */
@@ -2082,7 +2235,7 @@
drive->part[0].nr_sects = toc->capacity * SECTORS_PER_FRAME;
/* Remember that we've read this stuff. */
- CDROM_STATE_FLAGS (drive)->toc_valid = 1;
+ CDROM_STATE_FLAGS(drive)->toc_valid = 1;
return 0;
}
@@ -2308,7 +2461,7 @@
struct cdrom_tocentry *tocentry = (struct cdrom_tocentry*) arg;
struct atapi_toc_entry *toce;
- stat = cdrom_get_toc_entry (drive, tocentry->cdte_track, &toce);
+ stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce);
if (stat) return stat;
tocentry->cdte_ctrl = toce->control;
@@ -2380,10 +2533,10 @@
struct request_sense sense;
int stat;
- if ((stat = cdrom_select_speed (drive, speed, &sense)) < 0)
+ if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0)
return stat;
- cdi->speed = CDROM_STATE_FLAGS (drive)->current_speed;
+ cdi->speed = CDROM_STATE_FLAGS(drive)->current_speed;
return 0;
}
@@ -2476,8 +2629,8 @@
if (slot_nr == CDSL_CURRENT) {
(void) cdrom_check_status(drive, NULL);
- retval = CDROM_STATE_FLAGS (drive)->media_changed;
- CDROM_STATE_FLAGS (drive)->media_changed = 0;
+ retval = CDROM_STATE_FLAGS(drive)->media_changed;
+ CDROM_STATE_FLAGS(drive)->media_changed = 0;
return retval;
} else {
return -EINVAL;
@@ -2535,30 +2688,30 @@
struct cdrom_device_info *devinfo = &info->devinfo;
int minor = (drive->select.b.unit) << PARTN_BITS;
- devinfo->dev = MKDEV (HWIF(drive)->major, minor);
+ devinfo->dev = MKDEV(HWIF(drive)->major, minor);
devinfo->ops = &ide_cdrom_dops;
devinfo->mask = 0;
- devinfo->speed = CDROM_STATE_FLAGS (drive)->current_speed;
+ devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed;
devinfo->capacity = nslots;
devinfo->handle = (void *) drive;
strcpy(devinfo->name, drive->name);
/* set capability mask to match the probe. */
- if (!CDROM_CONFIG_FLAGS (drive)->cd_r)
+ if (!CDROM_CONFIG_FLAGS(drive)->cd_r)
devinfo->mask |= CDC_CD_R;
- if (!CDROM_CONFIG_FLAGS (drive)->cd_rw)
+ if (!CDROM_CONFIG_FLAGS(drive)->cd_rw)
devinfo->mask |= CDC_CD_RW;
- if (!CDROM_CONFIG_FLAGS (drive)->dvd)
+ if (!CDROM_CONFIG_FLAGS(drive)->dvd)
devinfo->mask |= CDC_DVD;
- if (!CDROM_CONFIG_FLAGS (drive)->dvd_r)
+ if (!CDROM_CONFIG_FLAGS(drive)->dvd_r)
devinfo->mask |= CDC_DVD_R;
- if (!CDROM_CONFIG_FLAGS (drive)->dvd_ram)
+ if (!CDROM_CONFIG_FLAGS(drive)->dvd_ram)
devinfo->mask |= CDC_DVD_RAM;
- if (!CDROM_CONFIG_FLAGS (drive)->is_changer)
+ if (!CDROM_CONFIG_FLAGS(drive)->is_changer)
devinfo->mask |= CDC_SELECT_DISC;
- if (!CDROM_CONFIG_FLAGS (drive)->audio_play)
+ if (!CDROM_CONFIG_FLAGS(drive)->audio_play)
devinfo->mask |= CDC_PLAY_AUDIO;
- if (!CDROM_CONFIG_FLAGS (drive)->close_tray)
+ if (!CDROM_CONFIG_FLAGS(drive)->close_tray)
devinfo->mask |= CDC_CLOSE_TRAY;
devinfo->de = devfs_register(drive->de, "cd", DEVFS_FL_DEFAULT,
@@ -2581,11 +2734,9 @@
* ACER50 (and others?) require the full spec length mode sense
* page capabilities size, but older drives break.
*/
- if (drive->id) {
- if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") ||
- !strcmp(drive->id->model, "WPI CDS-32X")))
- size -= sizeof(cap->pad);
- }
+ if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") ||
+ !strcmp(drive->id->model, "WPI CDS-32X")))
+ size -= sizeof(cap->pad);
/* we have to cheat a little here. the packet will eventually
* be queued with ide_cdrom_packet(), which extracts the
@@ -2612,9 +2763,9 @@
struct atapi_capabilities_page cap;
int nslots = 1;
- if (CDROM_CONFIG_FLAGS (drive)->nec260) {
- CDROM_CONFIG_FLAGS (drive)->no_eject = 0;
- CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
+ if (CDROM_CONFIG_FLAGS(drive)->nec260) {
+ CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
+ CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
return nslots;
}
@@ -2622,38 +2773,38 @@
return 0;
if (cap.lock == 0)
- CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
+ CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
if (cap.eject)
- CDROM_CONFIG_FLAGS (drive)->no_eject = 0;
+ CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
if (cap.cd_r_write)
- CDROM_CONFIG_FLAGS (drive)->cd_r = 1;
+ CDROM_CONFIG_FLAGS(drive)->cd_r = 1;
if (cap.cd_rw_write)
- CDROM_CONFIG_FLAGS (drive)->cd_rw = 1;
+ CDROM_CONFIG_FLAGS(drive)->cd_rw = 1;
if (cap.test_write)
- CDROM_CONFIG_FLAGS (drive)->test_write = 1;
+ CDROM_CONFIG_FLAGS(drive)->test_write = 1;
if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom)
- CDROM_CONFIG_FLAGS (drive)->dvd = 1;
+ CDROM_CONFIG_FLAGS(drive)->dvd = 1;
if (cap.dvd_ram_write)
- CDROM_CONFIG_FLAGS (drive)->dvd_ram = 1;
+ CDROM_CONFIG_FLAGS(drive)->dvd_ram = 1;
if (cap.dvd_r_write)
- CDROM_CONFIG_FLAGS (drive)->dvd_r = 1;
+ CDROM_CONFIG_FLAGS(drive)->dvd_r = 1;
if (cap.audio_play)
- CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
+ CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
if (cap.mechtype == mechtype_caddy || cap.mechtype == mechtype_popup)
- CDROM_CONFIG_FLAGS (drive)->close_tray = 0;
+ CDROM_CONFIG_FLAGS(drive)->close_tray = 0;
/* Some drives used by Apple don't advertise audio play
* but they do support reading TOC & audio datas
*/
- if (strcmp (drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
- strcmp (drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
- strcmp (drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
- strcmp (drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
- CDROM_CONFIG_FLAGS (drive)->audio_play = 1;
+ if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
+ strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
+ strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
+ strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
+ CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
#if ! STANDARD_ATAPI
if (cdi->sanyo_slot > 0) {
- CDROM_CONFIG_FLAGS (drive)->is_changer = 1;
+ CDROM_CONFIG_FLAGS(drive)->is_changer = 1;
nslots = 3;
}
@@ -2662,51 +2813,52 @@
if (cap.mechtype == mechtype_individual_changer ||
cap.mechtype == mechtype_cartridge_changer) {
if ((nslots = cdrom_number_of_slots(cdi)) > 1) {
- CDROM_CONFIG_FLAGS (drive)->is_changer = 1;
- CDROM_CONFIG_FLAGS (drive)->supp_disc_present = 1;
+ CDROM_CONFIG_FLAGS(drive)->is_changer = 1;
+ CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 1;
}
}
/* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */
- if (drive->id && !drive->id->model[0] && !strncmp(drive->id->fw_rev, "241N", 4)) {
- CDROM_STATE_FLAGS (drive)->current_speed =
+ if (!drive->id->model[0] &&
+ !strncmp(drive->id->fw_rev, "241N", 4)) {
+ CDROM_STATE_FLAGS(drive)->current_speed =
(((unsigned int)cap.curspeed) + (176/2)) / 176;
- CDROM_CONFIG_FLAGS (drive)->max_speed =
+ CDROM_CONFIG_FLAGS(drive)->max_speed =
(((unsigned int)cap.maxspeed) + (176/2)) / 176;
} else {
- CDROM_STATE_FLAGS (drive)->current_speed =
+ CDROM_STATE_FLAGS(drive)->current_speed =
(ntohs(cap.curspeed) + (176/2)) / 176;
- CDROM_CONFIG_FLAGS (drive)->max_speed =
+ CDROM_CONFIG_FLAGS(drive)->max_speed =
(ntohs(cap.maxspeed) + (176/2)) / 176;
}
/* don't print speed if the drive reported 0.
*/
- printk("%s: ATAPI", drive->name);
+ printk(KERN_INFO "%s: ATAPI", drive->name);
if (CDROM_CONFIG_FLAGS(drive)->max_speed)
printk(" %dX", CDROM_CONFIG_FLAGS(drive)->max_speed);
printk(" %s", CDROM_CONFIG_FLAGS(drive)->dvd ? "DVD-ROM" : "CD-ROM");
- if (CDROM_CONFIG_FLAGS (drive)->dvd_r|CDROM_CONFIG_FLAGS (drive)->dvd_ram)
- printk (" DVD%s%s",
- (CDROM_CONFIG_FLAGS (drive)->dvd_r)? "-R" : "",
- (CDROM_CONFIG_FLAGS (drive)->dvd_ram)? "-RAM" : "");
-
- if (CDROM_CONFIG_FLAGS (drive)->cd_r|CDROM_CONFIG_FLAGS (drive)->cd_rw)
- printk (" CD%s%s",
- (CDROM_CONFIG_FLAGS (drive)->cd_r)? "-R" : "",
- (CDROM_CONFIG_FLAGS (drive)->cd_rw)? "/RW" : "");
+ if (CDROM_CONFIG_FLAGS(drive)->dvd_r|CDROM_CONFIG_FLAGS(drive)->dvd_ram)
+ printk(" DVD%s%s",
+ (CDROM_CONFIG_FLAGS(drive)->dvd_r)? "-R" : "",
+ (CDROM_CONFIG_FLAGS(drive)->dvd_ram)? "-RAM" : "");
+
+ if (CDROM_CONFIG_FLAGS(drive)->cd_r|CDROM_CONFIG_FLAGS(drive)->cd_rw)
+ printk(" CD%s%s",
+ (CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "",
+ (CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : "");
- if (CDROM_CONFIG_FLAGS (drive)->is_changer)
- printk (" changer w/%d slots", nslots);
+ if (CDROM_CONFIG_FLAGS(drive)->is_changer)
+ printk(" changer w/%d slots", nslots);
else
- printk (" drive");
+ printk(" drive");
- printk (", %dkB Cache", be16_to_cpu(cap.buffer_size));
+ printk(", %dkB Cache", be16_to_cpu(cap.buffer_size));
#ifdef CONFIG_BLK_DEV_IDEDMA
if (drive->using_dma)
- (void) HWIF(drive)->dmaproc(ide_dma_verbose, drive);
+ (void) HWIF(drive)->ide_dma_verbose(drive);
#endif /* CONFIG_BLK_DEV_IDEDMA */
printk("\n");
@@ -2741,106 +2893,95 @@
drive->special.all = 0;
drive->ready_stat = 0;
- CDROM_STATE_FLAGS (drive)->media_changed = 1;
- CDROM_STATE_FLAGS (drive)->toc_valid = 0;
- CDROM_STATE_FLAGS (drive)->door_locked = 0;
+ CDROM_STATE_FLAGS(drive)->media_changed = 1;
+ CDROM_STATE_FLAGS(drive)->toc_valid = 0;
+ CDROM_STATE_FLAGS(drive)->door_locked = 0;
#if NO_DOOR_LOCKING
- CDROM_CONFIG_FLAGS (drive)->no_doorlock = 1;
+ CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
#else
- CDROM_CONFIG_FLAGS (drive)->no_doorlock = 0;
+ CDROM_CONFIG_FLAGS(drive)->no_doorlock = 0;
#endif
- if (drive->id != NULL)
- CDROM_CONFIG_FLAGS (drive)->drq_interrupt =
- ((drive->id->config & 0x0060) == 0x20);
- else
- CDROM_CONFIG_FLAGS (drive)->drq_interrupt = 0;
+ CDROM_CONFIG_FLAGS(drive)->drq_interrupt =
+ ((drive->id->config & 0x0060) == 0x20);
- CDROM_CONFIG_FLAGS (drive)->is_changer = 0;
- CDROM_CONFIG_FLAGS (drive)->cd_r = 0;
- CDROM_CONFIG_FLAGS (drive)->cd_rw = 0;
- CDROM_CONFIG_FLAGS (drive)->test_write = 0;
- CDROM_CONFIG_FLAGS (drive)->dvd = 0;
- CDROM_CONFIG_FLAGS (drive)->dvd_r = 0;
- CDROM_CONFIG_FLAGS (drive)->dvd_ram = 0;
- CDROM_CONFIG_FLAGS (drive)->no_eject = 1;
- CDROM_CONFIG_FLAGS (drive)->supp_disc_present = 0;
- CDROM_CONFIG_FLAGS (drive)->audio_play = 0;
- CDROM_CONFIG_FLAGS (drive)->close_tray = 1;
+ CDROM_CONFIG_FLAGS(drive)->is_changer = 0;
+ CDROM_CONFIG_FLAGS(drive)->cd_r = 0;
+ CDROM_CONFIG_FLAGS(drive)->cd_rw = 0;
+ CDROM_CONFIG_FLAGS(drive)->test_write = 0;
+ CDROM_CONFIG_FLAGS(drive)->dvd = 0;
+ CDROM_CONFIG_FLAGS(drive)->dvd_r = 0;
+ CDROM_CONFIG_FLAGS(drive)->dvd_ram = 0;
+ CDROM_CONFIG_FLAGS(drive)->no_eject = 1;
+ CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0;
+ CDROM_CONFIG_FLAGS(drive)->audio_play = 0;
+ CDROM_CONFIG_FLAGS(drive)->close_tray = 1;
/* limit transfer size per interrupt. */
- CDROM_CONFIG_FLAGS (drive)->limit_nframes = 0;
- if (drive->id != NULL) {
- /* a testament to the nice quality of Samsung drives... */
- if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430"))
- CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
- else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432"))
- CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
- /* the 3231 model does not support the SET_CD_SPEED command */
- else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231"))
- cdi->mask |= CDC_SELECT_SPEED;
- }
+ CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0;
+
+ /* a testament to the nice quality of Samsung drives... */
+ if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2430"))
+ CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1;
+ else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-2432"))
+ CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1;
+ /* the 3231 model does not support the SET_CD_SPEED command */
+ else if (!strcmp(drive->id->model, "SAMSUNG CD-ROM SCR-3231"))
+ cdi->mask |= CDC_SELECT_SPEED;
#if ! STANDARD_ATAPI
/* by default Sanyo 3 CD changer support is turned off and
ATAPI Rev 2.2+ standard support for CD changers is used */
cdi->sanyo_slot = 0;
- CDROM_CONFIG_FLAGS (drive)->nec260 = 0;
- CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 0;
- CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 0;
- CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 0;
- CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 0;
-
- if (drive->id != NULL) {
- if (strcmp (drive->id->model, "V003S0DS") == 0 &&
- drive->id->fw_rev[4] == '1' &&
- drive->id->fw_rev[6] <= '2') {
- /* Vertos 300.
- Some versions of this drive like to talk BCD. */
- CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1;
- 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 &&
- 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,
- "NEC CD-ROM DRIVE:260") == 0 &&
- strncmp (drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */
- /* Old NEC260 (not R).
- This drive was released before the 1.2 version
- of the spec. */
- CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 1;
- 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 &&
- strncmp (drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */
- /* Wearnes */
- CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1;
- CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1;
- }
-
- /* Sanyo 3 CD changer uses a non-standard command
- for CD changing */
- else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) ||
- (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) ||
- (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) {
- /* uses CD in slot 0 when value is set to 3 */
- cdi->sanyo_slot = 3;
- }
-
-
+ CDROM_CONFIG_FLAGS(drive)->nec260 = 0;
+ CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 0;
+ CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 0;
+ CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 0;
+ CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 0;
+
+ if (strcmp (drive->id->model, "V003S0DS") == 0 &&
+ drive->id->fw_rev[4] == '1' &&
+ drive->id->fw_rev[6] <= '2') {
+ /* Vertos 300.
+ Some versions of this drive like to talk BCD. */
+ CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd = 1;
+ 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 &&
+ 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,
+ "NEC CD-ROM DRIVE:260") == 0 &&
+ strncmp(drive->id->fw_rev, "1.01", 4) == 0) { /* FIXME */
+ /* Old NEC260 (not R).
+ This drive was released before the 1.2 version
+ of the spec. */
+ CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd = 1;
+ 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 &&
+ strncmp(drive->id->fw_rev, "A1.1", 4) == 0) { /* FIXME */
+ /* Wearnes */
+ CDROM_CONFIG_FLAGS(drive)->playmsf_as_bcd = 1;
+ CDROM_CONFIG_FLAGS(drive)->subchan_as_bcd = 1;
+ }
+ /* Sanyo 3 CD changer uses a non-standard command
+ for CD changing */
+ else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) ||
+ (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) ||
+ (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) {
+ /* uses CD in slot 0 when value is set to 3 */
+ cdi->sanyo_slot = 3;
}
#endif /* not STANDARD_ATAPI */
@@ -2857,7 +2998,16 @@
if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
set_device_ro(MKDEV(HWIF(drive)->major, minor), 0);
- if (ide_cdrom_register (drive, nslots)) {
+#if 0
+ drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
+ if (HWIF(drive)->no_dsc) {
+ printk(KERN_INFO "ide-cd: %s: disabling DSC overlap\n",
+ drive->name);
+ drive->dsc_overlap = 0;
+ }
+#endif
+
+ if (ide_cdrom_register(drive, nslots)) {
printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
info->devinfo.handle = NULL;
return 1;
@@ -2872,7 +3022,7 @@
struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- return cdrom_ioctl (inode, file, cmd, arg);
+ return cdrom_ioctl(inode, file, cmd, arg);
}
static
@@ -2902,7 +3052,7 @@
static
int ide_cdrom_check_media_change (ide_drive_t *drive)
{
- return cdrom_media_changed(MKDEV (HWIF (drive)->major,
+ return cdrom_media_changed(MKDEV (HWIF(drive)->major,
(drive->select.b.unit) << PARTN_BITS));
}
@@ -2950,22 +3100,26 @@
struct cdrom_info *info = drive->driver_data;
struct cdrom_device_info *devinfo = &info->devinfo;
- if (ide_unregister_subdriver (drive))
+ if (ide_unregister_subdriver(drive)) {
+ printk("%s: %s: failed to ide_unregister_subdriver\n",
+ __FUNCTION__, drive->name);
return 1;
+ }
if (info->buffer != NULL)
kfree(info->buffer);
if (info->toc != NULL)
kfree(info->toc);
if (info->changer_info != NULL)
kfree(info->changer_info);
- if (devinfo->handle == drive && unregister_cdrom (devinfo))
- printk ("%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
+ if (devinfo->handle == drive && unregister_cdrom(devinfo))
+ printk("%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
kfree(info);
drive->driver_data = NULL;
return 0;
}
-int ide_cdrom_reinit (ide_drive_t *drive);
+int ide_cdrom_init(void);
+int ide_cdrom_attach (ide_drive_t *drive);
static ide_driver_t ide_cdrom_driver = {
name: "ide-cdrom",
@@ -2976,9 +3130,14 @@
supports_dsc_overlap: 1,
cleanup: ide_cdrom_cleanup,
standby: NULL,
+ suspend: NULL,
+ resume: NULL,
flushcache: NULL,
do_request: ide_do_rw_cdrom,
- end_request: NULL,
+ end_request: ide_cdrom_end_request,
+ sense: ide_cdrom_dump_status,
+ error: ide_cdrom_error,
+ abort: ide_cdrom_abort,
ioctl: ide_cdrom_ioctl,
open: ide_cdrom_open,
release: ide_cdrom_release,
@@ -2988,12 +3147,12 @@
capacity: ide_cdrom_capacity,
special: NULL,
proc: NULL,
- reinit: ide_cdrom_reinit,
+ init: ide_cdrom_init,
+ attach: ide_cdrom_attach,
ata_prebuilder: NULL,
atapi_prebuilder: NULL,
};
-int ide_cdrom_init(void);
static ide_module_t ide_cdrom_module = {
IDE_DRIVER_MODULE,
ide_cdrom_init,
@@ -3007,35 +3166,46 @@
MODULE_PARM(ignore, "s");
MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
-int ide_cdrom_reinit (ide_drive_t *drive)
+int ide_cdrom_attach (ide_drive_t *drive)
{
struct cdrom_info *info;
int failed = 0;
+ if (drive->scsi) {
+ printk("ide-cd: passing drive %s to ide-scsi emulation.\n",
+ drive->name);
+ return 1;
+ }
+
MOD_INC_USE_COUNT;
info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
if (info == NULL) {
- printk ("%s: Can't allocate a cdrom structure\n", drive->name);
+ printk("%s: Can't allocate a cdrom structure\n", drive->name);
+ MOD_DEC_USE_COUNT;
return 1;
}
- if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
- printk ("%s: Failed to register the driver with ide.c\n", drive->name);
- kfree (info);
+ if (ide_register_subdriver(drive,
+ &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
+ printk(KERN_ERR "ide-cd: %s: Failed to register the driver "
+ "with ide.c\n", drive->name);
+ kfree(info);
+ MOD_DEC_USE_COUNT;
return 1;
}
- memset (info, 0, sizeof (struct cdrom_info));
+ memset(info, 0, sizeof(struct cdrom_info));
drive->driver_data = info;
DRIVER(drive)->busy++;
- if (ide_cdrom_setup (drive)) {
+ if (ide_cdrom_setup(drive)) {
DRIVER(drive)->busy--;
- if (ide_cdrom_cleanup (drive))
- printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
+ if (ide_cdrom_cleanup(drive))
+ printk("%s: ide_cdrom_cleanup failed in "
+ "ide_cdrom_init\n", drive->name);
+ MOD_DEC_USE_COUNT;
return 1;
}
DRIVER(drive)->busy--;
failed--;
- ide_register_module(&ide_cdrom_module);
MOD_DEC_USE_COUNT;
return 0;
}
@@ -3045,41 +3215,51 @@
ide_drive_t *drive;
int failed = 0;
- while ((drive = ide_scan_devices (ide_cdrom, ide_cdrom_driver.name, &ide_cdrom_driver, failed)) != NULL)
- if (ide_cdrom_cleanup (drive)) {
- printk ("%s: cleanup_module() called while still busy\n", drive->name);
+ while ((drive = ide_scan_devices(ide_cdrom, ide_cdrom_driver.name,
+ &ide_cdrom_driver, failed)) != NULL)
+ if (ide_cdrom_cleanup(drive)) {
+ printk("%s: cleanup_module() called while still "
+ "busy\n", drive->name);
failed++;
}
- ide_unregister_module (&ide_cdrom_module);
+ ide_unregister_module(&ide_cdrom_module);
}
-
+
int ide_cdrom_init(void)
{
+#ifdef CLASSIC_BUILTINS_METHOD
ide_drive_t *drive;
struct cdrom_info *info;
int failed = 0;
-
+#endif /* CLASSIC_BUILTINS_METHOD */
MOD_INC_USE_COUNT;
- while ((drive = ide_scan_devices (ide_cdrom, ide_cdrom_driver.name, NULL, failed++)) != NULL) {
+#ifdef CLASSIC_BUILTINS_METHOD
+ while ((drive = ide_scan_devices(ide_cdrom,
+ ide_cdrom_driver.name, NULL, failed++)) != NULL) {
/* skip drives that we were told to ignore */
if (ignore != NULL) {
if (strstr(ignore, drive->name)) {
- printk("ide-cd: ignoring drive %s\n", drive->name);
+ printk("ide-cd: ignoring drive %s\n",
+ drive->name);
continue;
}
}
if (drive->scsi) {
- printk("ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
+ printk("ide-cd: passing drive %s to ide-scsi "
+ "emulation.\n", drive->name);
continue;
}
info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
if (info == NULL) {
- printk ("%s: Can't allocate a cdrom structure\n", drive->name);
+ printk ("%s: Can't allocate a cdrom structure\n",
+ drive->name);
continue;
}
- if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
- printk ("%s: Failed to register the driver with ide.c\n", drive->name);
- kfree (info);
+ if (ide_register_subdriver(drive,
+ &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) {
+ printk("%s: Failed to register the driver with "
+ "ide.c\n", drive->name);
+ kfree(info);
continue;
}
memset (info, 0, sizeof (struct cdrom_info));
@@ -3088,12 +3268,14 @@
if (ide_cdrom_setup (drive)) {
DRIVER(drive)->busy--;
if (ide_cdrom_cleanup (drive))
- printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
+ printk ("%s: ide_cdrom_cleanup failed in "
+ "ide_cdrom_init\n", drive->name);
continue;
}
DRIVER(drive)->busy--;
failed--;
}
+#endif /* CLASSIC_BUILTINS_METHOD */
ide_register_module(&ide_cdrom_module);
MOD_DEC_USE_COUNT;
return 0;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)