s = "(reserved error code)";
}
- printk(" %s -- (asc=0x%02x, ascq=0x%02x)\n",
+ printk(KERN_ERR " %s -- (asc=0x%02x, ascq=0x%02x)\n",
s, sense->asc, sense->ascq);
if (failed_command != NULL) {
lo = mid+1;
}
- printk (" The failed \"%s\" packet command was: \n \"", s);
+ printk (KERN_ERR " The failed \"%s\" packet command was: \n \"", s);
for (i=0; i<sizeof (failed_command->cmd); i++)
printk ("%02x ", failed_command->cmd[i]);
printk ("\"\n");
*/
if (sense->sense_key == NOT_READY && (sense->sks[0] & 0x80)) {
int progress = (sense->sks[1] << 8 | sense->sks[2]) * 100;
- printk(" Command is %02d%% complete\n", progress / 0xffff);
+ printk(KERN_ERR " Command is %02d%% complete\n", progress / 0xffff);
}
if (sense->sense_key == ILLEGAL_REQUEST &&
(sense->sks[0] & 0x80) != 0) {
- printk(" Error in %s byte %d",
+ printk(KERN_ERR " Error in %s byte %d",
(sense->sks[0] & 0x40) != 0 ?
"command packet" : "command data",
(sense->sks[1] << 8) + sense->sks[2]);
sense->asc == 0x3a)))
return;
- printk("%s: error code: 0x%02x sense_key: 0x%02x asc: 0x%02x ascq: 0x%02x\n",
+ printk(KERN_ERR "%s: error code: 0x%02x sense_key: 0x%02x asc: 0x%02x ascq: 0x%02x\n",
drive->name,
sense->error_code, sense->sense_key,
sense->asc, sense->ascq);
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
}
-/*
- * 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_dump_atapi_status(drive, msg, stat);
- if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
- return ide_stopped;
- /* retry only "normal" I/O: */
- if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) {
- 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, 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->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) {
- rq->errors = 1;
- ide_end_drive_cmd(drive, BUSY_STAT, 0);
- return ide_stopped;
- }
- rq->errors |= ERROR_RESET;
- DRIVER(drive)->end_request(drive, 0, 0);
- return ide_stopped;
-}
-
static void cdrom_end_request (ide_drive_t *drive, int uptodate)
{
struct request *rq = HWGROUP(drive)->rq;
rq->flags |= REQ_FAILED;
cdrom_end_request(drive, 0);
- DRIVER(drive)->error(drive, "request sense failure", stat);
+ ide_error(drive, "request sense failure", stat);
return 1;
} else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) {
} else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler
for other errors. */
- DRIVER(drive)->error(drive, "cdrom_decode_status",stat);
+ ide_error(drive, "cdrom_decode_status", stat);
return 1;
} else if ((++rq->errors > ERROR_MAX)) {
/* We've racked up too many retries. Abort. */
{
ide_startstop_t startstop;
struct cdrom_info *info = drive->driver_data;
+ ide_hwif_t *hwif = drive->hwif;
/* Wait for the controller to be idle. */
if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY))
return startstop;
- if (info->dma) {
- if (info->cmd == READ) {
- info->dma = !HWIF(drive)->ide_dma_read(drive);
- } else if (info->cmd == WRITE) {
- info->dma = !HWIF(drive)->ide_dma_write(drive);
- } else {
- printk("ide-cd: DMA set, but not allowed\n");
- }
- }
+ if (info->dma)
+ info->dma = !hwif->dma_setup(drive);
/* Set up the controller registers. */
/* FIXME: for Virtual DMA we must check harder */
ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry);
return ide_started;
} else {
+ unsigned long flags;
+
/* packet command */
- HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
+ spin_lock_irqsave(&ide_lock, flags);
+ hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG);
+ ndelay(400);
+ spin_unlock_irqrestore(&ide_lock, flags);
+
return (*handler) (drive);
}
}
struct request *rq,
ide_handler_t *handler)
{
+ ide_hwif_t *hwif = drive->hwif;
int cmd_len;
struct cdrom_info *info = drive->driver_data;
ide_startstop_t startstop;
/* Start the DMA if need be */
if (info->dma)
- (void) HWIF(drive)->ide_dma_begin(drive);
+ hwif->dma_start(drive);
return ide_started;
}
return 0;
else if (ireason == 0) {
/* Whoops... The drive is expecting to receive data from us! */
- printk("%s: read_intr: Drive wants to transfer data the "
+ printk(KERN_ERR "%s: read_intr: Drive wants to transfer data the "
"wrong way!\n", drive->name);
/* Throw some data at the drive so it doesn't hang
return 0;
} else {
/* Drive wants a command packet, or invalid ireason... */
- printk("%s: read_intr: bad interrupt reason %x\n", drive->name,
+ printk(KERN_ERR "%s: read_intr: bad interrupt reason %x\n", drive->name,
ireason);
}
ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped;
} else
- return DRIVER(drive)->error(drive, "dma error", stat);
+ return ide_error(drive, "dma error", stat);
}
/* Read the interrupt reason and the transfer length. */
/* If we're not done filling the current buffer, complain.
Otherwise, complete the command normally. */
if (rq->current_nr_sectors > 0) {
- printk ("%s: cdrom_read_intr: data underrun (%d blocks)\n",
+ printk (KERN_ERR "%s: cdrom_read_intr: data underrun (%d blocks)\n",
drive->name, rq->current_nr_sectors);
rq->flags |= REQ_FAILED;
cdrom_end_request(drive, 0);
of at least SECTOR_SIZE, as it gets hairy to keep track
of the transfers otherwise. */
if ((len % SECTOR_SIZE) != 0) {
- printk ("%s: cdrom_read_intr: Bad transfer size %d\n",
+ printk (KERN_ERR "%s: cdrom_read_intr: Bad transfer size %d\n",
drive->name, len);
if (CDROM_CONFIG_FLAGS(drive)->limit_nframes)
- printk (" This drive is not supported by this version of the driver\n");
+ printk (KERN_ERR " This drive is not supported by this version of the driver\n");
else {
- printk (" Trying to limit transfer sizes\n");
+ printk (KERN_ERR " Trying to limit transfer sizes\n");
CDROM_CONFIG_FLAGS(drive)->limit_nframes = 1;
}
cdrom_end_request(drive, 0);
paranoid and check. */
if (rq->current_nr_sectors < bio_cur_sectors(rq->bio) &&
(rq->sector & (sectors_per_frame - 1))) {
- printk("%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
+ printk(KERN_ERR "%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
drive->name, (long)rq->sector);
cdrom_end_request(drive, 0);
return -1;
/* Sanity check... */
if (rq->current_nr_sectors != bio_cur_sectors(rq->bio) &&
(rq->sector & (sectors_per_frame - 1))) {
- printk ("%s: cdrom_start_read_continuation: buffer botch (%u)\n",
+ printk(KERN_ERR "%s: cdrom_start_read_continuation: buffer botch (%u)\n",
drive->name, rq->current_nr_sectors);
cdrom_end_request(drive, 0);
return ide_stopped;
rq->sense_len += thislen;
} else {
confused:
- printk ("%s: cdrom_pc_intr: The drive "
+ printk (KERN_ERR "%s: cdrom_pc_intr: The drive "
"appears confused (ireason = 0x%02x)\n",
drive->name, ireason);
rq->flags |= REQ_FAILED;
}
-/* Sleep for TIME jiffies.
- Not to be called from an interrupt handler. */
-static
-void cdrom_sleep (int time)
-{
- int sleep = time;
-
- do {
- set_current_state(TASK_INTERRUPTIBLE);
- sleep = schedule_timeout(sleep);
- } while (sleep);
-}
-
static
int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq)
{
/* The drive is in the process of loading
a disk. Retry, but wait a little to give
the drive time to complete the load. */
- cdrom_sleep(2 * HZ);
+ ssleep(2);
} else {
/* Otherwise, don't retry. */
retries = 0;
return 0;
else if (ireason == 2) {
/* Whoops... The drive wants to send data. */
- printk("%s: write_intr: wrong transfer direction!\n",
+ printk(KERN_ERR "%s: write_intr: wrong transfer direction!\n",
drive->name);
while (len > 0) {
}
} else {
/* Drive wants a command packet, or invalid ireason... */
- printk("%s: write_intr: bad interrupt reason %x\n",
+ printk(KERN_ERR "%s: write_intr: bad interrupt reason %x\n",
drive->name, ireason);
}
*/
if (dma) {
if (dma_error) {
- printk("ide-cd: dma error\n");
+ printk(KERN_ERR "ide-cd: dma error\n");
__ide_dma_off(drive);
- return DRIVER(drive)->error(drive, "dma error", stat);
+ return ide_error(drive, "dma error", stat);
}
end_that_request_chunk(rq, 1, rq->data_len);
}
if (!ptr) {
- printk("%s: confused, missing data\n", drive->name);
+ printk(KERN_ERR "%s: confused, missing data\n", drive->name);
break;
}
if (dma) {
info->dma = 0;
if ((dma_error = HWIF(drive)->ide_dma_end(drive))) {
- printk("ide-cd: write dma error\n");
+ printk(KERN_ERR "ide-cd: write dma error\n");
__ide_dma_off(drive);
}
}
*/
if (dma) {
if (dma_error)
- return DRIVER(drive)->error(drive, "dma error", stat);
+ return ide_error(drive, "dma error", stat);
ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped;
*/
uptodate = 1;
if (rq->current_nr_sectors > 0) {
- printk("%s: write_intr: data underrun (%d blocks)\n",
+ printk(KERN_ERR "%s: write_intr: data underrun (%d blocks)\n",
drive->name, rq->current_nr_sectors);
uptodate = 0;
}
int this_transfer;
if (!rq->current_nr_sectors) {
- printk("ide-cd: write_intr: oops\n");
+ printk(KERN_ERR "ide-cd: write_intr: oops\n");
break;
}
info->dma = drive->using_dma ? 1 : 0;
info->cmd = WRITE;
+ info->devinfo.media_written = 1;
+
/* Start sending the write request to the drive. */
return cdrom_start_packet_command(drive, 32768, cdrom_start_write_cont);
}
ide_stall_queue(drive, IDECD_SEEK_TIMER);
return ide_stopped;
}
- printk ("%s: DSC timeout\n", drive->name);
+ printk (KERN_ERR "%s: DSC timeout\n", drive->name);
}
CDROM_CONFIG_FLAGS(drive)->seeking = 0;
}
- if (IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) {
+ if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) {
action = cdrom_start_seek(drive, block);
} else {
if (rq_data_dir(rq) == READ)
if (stat != 0 &&
sense->sense_key == ILLEGAL_REQUEST &&
(sense->asc == 0x24 || sense->asc == 0x20)) {
- printk ("%s: door locking not supported\n",
+ printk (KERN_ERR "%s: door locking not supported\n",
drive->name);
CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1;
stat = 0;
GFP_KERNEL);
info->toc = toc;
if (toc == NULL) {
- printk ("%s: No cdrom TOC buffer!\n", drive->name);
+ printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);
return -ENOMEM;
}
}
/* Read the multisession information. */
if (toc->hdr.first_track != CDROM_LEADOUT) {
/* Read the multisession information. */
- stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
+ stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,
sizeof(ms_tmp), sense);
if (stat) return stat;
+
+ toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba);
} else {
- ms_tmp.ent.addr.msf.minute = 0;
- ms_tmp.ent.addr.msf.second = 2;
- ms_tmp.ent.addr.msf.frame = 0;
ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT;
+ toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */
}
#if ! STANDARD_ATAPI
- if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd)
+ if (CDROM_CONFIG_FLAGS(drive)->tocaddr_as_bcd) {
+ /* Re-read multisession information using MSF format */
+ stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
+ sizeof(ms_tmp), sense);
+ if (stat)
+ return stat;
+
msf_from_bcd (&ms_tmp.ent.addr.msf);
+ toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,
+ ms_tmp.ent.addr.msf.second,
+ ms_tmp.ent.addr.msf.frame);
+ }
#endif /* not STANDARD_ATAPI */
- toc->last_session_lba = msf_to_lba (ms_tmp.ent.addr.msf.minute,
- ms_tmp.ent.addr.msf.second,
- ms_tmp.ent.addr.msf.frame);
-
toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track);
/* Now try to get the total cdrom capacity. */
*/
if (sense.sense_key == NOT_READY) {
if (sense.asc == 0x3a) {
- if (sense.ascq == 0 || sense.ascq == 1)
+ if (sense.ascq == 1)
return CDS_NO_DISC;
- else if (sense.ascq == 2)
+ else if (sense.ascq == 0 || sense.ascq == 2)
return CDS_TRAY_OPEN;
}
}
if (drive->media == ide_optical) {
CDROM_CONFIG_FLAGS(drive)->mo_drive = 1;
CDROM_CONFIG_FLAGS(drive)->ram = 1;
- printk("%s: ATAPI magneto-optical drive\n", drive->name);
+ printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name);
return nslots;
}
CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
if (cap.cd_r_write)
CDROM_CONFIG_FLAGS(drive)->cd_r = 1;
- if (cap.cd_rw_write)
+ if (cap.cd_rw_write) {
CDROM_CONFIG_FLAGS(drive)->cd_rw = 1;
+ CDROM_CONFIG_FLAGS(drive)->ram = 1;
+ }
if (cap.test_write)
CDROM_CONFIG_FLAGS(drive)->test_write = 1;
if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom)
/* 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");
printk(", %dkB Cache", be16_to_cpu(cap.buffer_size));
-#ifdef CONFIG_BLK_DEV_IDEDMA
if (drive->using_dma)
- (void) HWIF(drive)->ide_dma_verbose(drive);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+ ide_dma_verbose(drive);
+
printk("\n");
return nslots;
#endif
if (ide_cdrom_register(drive, nslots)) {
- printk ("%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
+ printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
info->devinfo.handle = NULL;
return 1;
}
struct gendisk *g = drive->disk;
if (ide_unregister_subdriver(drive)) {
- printk("%s: %s: failed to ide_unregister_subdriver\n",
+ printk(KERN_ERR "%s: %s: failed to ide_unregister_subdriver\n",
__FUNCTION__, drive->name);
return 1;
}
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);
+ printk(KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
kfree(info);
drive->driver_data = NULL;
blk_queue_prep_rq(drive->queue, NULL);
.supports_dsc_overlap = 1,
.cleanup = ide_cdrom_cleanup,
.do_request = ide_do_rw_cdrom,
- .sense = ide_dump_atapi_status,
- .error = ide_cdrom_error,
- .abort = ide_cdrom_abort,
.capacity = ide_cdrom_capacity,
.attach = ide_cdrom_attach,
.drives = LIST_HEAD_INIT(ide_cdrom_driver.drives),
};
/* options */
-char *ignore = NULL;
+static char *ignore = NULL;
-MODULE_PARM(ignore, "s");
+module_param(ignore, charp, 0400);
MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cdrom_attach (ide_drive_t *drive)
/* 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(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name);
goto failed;
}
}
if (drive->scsi) {
- printk("ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
+ printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
goto failed;
}
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(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
goto failed;
}
if (ide_register_subdriver(drive, &ide_cdrom_driver)) {
- printk("%s: Failed to register the driver with ide.c\n",
+ printk(KERN_ERR "%s: Failed to register the driver with ide.c\n",
drive->name);
kfree(info);
goto failed;
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);
+ printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
kfree(info);
drive->driver_data = NULL;
goto failed;