X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fide%2Fide-cd.c;h=a4ad198c4e25dd5c9f6a324241166fe8ebffae64;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=95a44a93b873389df20cdd8246ac68c470d3493f;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 95a44a93b..a4ad198c4 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -456,7 +456,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, 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) { @@ -478,7 +478,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, 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; icmd); i++) printk ("%02x ", failed_command->cmd[i]); printk ("\"\n"); @@ -491,13 +491,13 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, */ 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]); @@ -519,7 +519,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, 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); @@ -535,9 +535,7 @@ static void cdrom_prepare_request(struct request *rq) rq->flags = REQ_PC; } -static void cdrom_queue_request_sense(ide_drive_t *drive, - struct completion *wait, - void *sense, +static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, struct request *failed_command) { struct cdrom_info *info = drive->driver_data; @@ -554,7 +552,6 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, rq->cmd[4] = rq->data_len = 18; rq->flags = REQ_SENSE; - rq->waiting = wait; /* NOTE! Save the failed command in "rq->buffer" */ rq->buffer = (void *) failed_command; @@ -562,62 +559,6 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, (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)) { - 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)) { - 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; @@ -631,10 +572,21 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) struct request *failed = (struct request *) rq->buffer; struct cdrom_info *info = drive->driver_data; void *sense = &info->sense_data; - - if (failed && failed->sense) { - sense = failed->sense; - failed->sense_len = rq->sense_len; + unsigned long flags; + + if (failed) { + if (failed->sense) { + sense = failed->sense; + failed->sense_len = rq->sense_len; + } + + /* + * now end failed request + */ + spin_lock_irqsave(&ide_lock, flags); + end_that_request_chunk(failed, 0, failed->data_len); + end_that_request_last(failed); + spin_unlock_irqrestore(&ide_lock, flags); } cdrom_analyze_sense_data(drive, failed, sense); @@ -642,6 +594,9 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) if (!rq->current_nr_sectors && blk_fs_request(rq)) uptodate = 1; + /* make sure it's fully ended */ + if (blk_pc_request(rq)) + nsectors = (rq->data_len + 511) >> 9; if (!nsectors) nsectors = 1; @@ -679,12 +634,12 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) 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)) { /* All other functions, except for READ. */ - struct completion *wait = NULL; + unsigned long flags; /* * if we have an error, pass back CHECK_CONDITION as the @@ -706,30 +661,23 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) ide_dump_status(drive, "packet command error", stat); } - /* Set the error flag and complete the request. - Then, if we have a CHECK CONDITION status, - queue a request sense command. We must be careful, - though: we don't want the thread in - cdrom_queue_packet_command to wake up until - the request sense has completed. We do this - by transferring the semaphore from the packet - command request to the request sense request. */ - rq->flags |= REQ_FAILED; - if ((stat & ERR_STAT) != 0) { - wait = rq->waiting; - rq->waiting = NULL; - if ((rq->flags & REQ_BLOCK_PC) != 0) { - cdrom_queue_request_sense(drive, wait, - rq->sense, rq); - return 1; /* REQ_BLOCK_PC self-cares */ - } - } - cdrom_end_request(drive, 0); + /* + * instead of playing games with moving completions around, + * remove failed request completely and end it when the + * request sense has completed + */ + if (stat & ERR_STAT) { + spin_lock_irqsave(&ide_lock, flags); + blkdev_dequeue_request(rq); + HWGROUP(drive)->rq = NULL; + spin_unlock_irqrestore(&ide_lock, flags); + + cdrom_queue_request_sense(drive, rq->sense, rq); + } else + cdrom_end_request(drive, 0); - if ((stat & ERR_STAT) != 0) - cdrom_queue_request_sense(drive, wait, rq->sense, rq); } else if (blk_fs_request(rq)) { int do_end_request = 0; @@ -781,14 +729,6 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) do_end_request = 1; } else if (sense_key == ILLEGAL_REQUEST || sense_key == DATA_PROTECT) { - /* - * check if this was a write protected media - */ - if (rq_data_dir(rq) == WRITE) { - printk("ide-cd: media marked write protected\n"); - set_disk_ro(drive->disk, 1); - } - /* No point in retrying after an illegal request or data protect error.*/ ide_dump_status (drive, "command error", stat); @@ -805,7 +745,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) } 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. */ @@ -818,7 +758,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) /* If we got a CHECK_CONDITION status, queue a request sense command. */ if ((stat & ERR_STAT) != 0) - cdrom_queue_request_sense(drive, NULL, NULL, NULL); + cdrom_queue_request_sense(drive, NULL, NULL); } else { blk_dump_rq_flags(rq, "ide-cd: bad rq"); cdrom_end_request(drive, 0); @@ -869,20 +809,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, { 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 */ @@ -900,8 +834,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, 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); } } @@ -920,6 +860,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *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; @@ -951,7 +892,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, /* Start the DMA if need be */ if (info->dma) - (void) HWIF(drive)->ide_dma_begin(drive); + hwif->dma_start(drive); return ide_started; } @@ -1017,7 +958,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) 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 @@ -1035,7 +976,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) 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); } @@ -1073,7 +1014,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) 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. */ @@ -1088,7 +1029,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) /* 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); @@ -1105,12 +1046,12 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) 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); @@ -1224,7 +1165,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) 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; @@ -1259,7 +1200,7 @@ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) /* 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; @@ -1484,7 +1425,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) 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; @@ -1523,19 +1464,6 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive) } -/* 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) { @@ -1570,7 +1498,7 @@ 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; @@ -1598,7 +1526,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire 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) { @@ -1608,7 +1536,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire } } 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); } @@ -1666,23 +1594,17 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) dma_error = HWIF(drive)->ide_dma_end(drive); } - if (cdrom_decode_status(drive, 0, &stat)) { - if ((stat & ERR_STAT) != 0) { - end_that_request_chunk(rq, 0, rq->data_len); - goto end_request; /* purge the whole thing... */ - } - end_that_request_chunk(rq, 1, rq->data_len); + if (cdrom_decode_status(drive, 0, &stat)) return ide_stopped; - } /* * using dma, transfer is complete now */ 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); @@ -1745,7 +1667,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) } if (!ptr) { - printk("%s: confused, missing data\n", drive->name); + printk(KERN_ERR "%s: confused, missing data\n", drive->name); break; } @@ -1807,7 +1729,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) 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); } } @@ -1820,7 +1742,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *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; @@ -1840,7 +1762,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) */ 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; } @@ -1861,7 +1783,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) 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; } @@ -1942,6 +1864,8 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) 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); } @@ -1969,13 +1893,17 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) * sg request */ if (rq->bio) { - if (rq->data_len & 3) { - printk("%s: block pc not aligned, len=%d\n", drive->name, rq->data_len); - cdrom_end_request(drive, 0); - return ide_stopped; - } - info->dma = drive->using_dma; + int mask = drive->queue->dma_alignment; + unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); + info->cmd = rq_data_dir(rq); + info->dma = drive->using_dma; + + /* + * check if dma is safe + */ + if ((rq->data_len & mask) || (addr & mask)) + info->dma = 0; } /* Start sending the command to the drive. */ @@ -2001,11 +1929,11 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) 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) @@ -2137,7 +2065,7 @@ cdrom_lockdoor(ide_drive_t *drive, int lockflag, struct request_sense *sense) 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; @@ -2255,7 +2183,7 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) 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; } } @@ -2362,25 +2290,31 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense) /* 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. */ @@ -2491,7 +2425,7 @@ static int cdrom_get_toc_entry(ide_drive_t *drive, int track, /* the generic packet interface to cdrom.c */ static int ide_cdrom_packet(struct cdrom_device_info *cdi, - struct cdrom_generic_command *cgc) + struct packet_command *cgc) { struct request req; ide_drive_t *drive = (ide_drive_t*) cdi->handle; @@ -2524,7 +2458,7 @@ static int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, unsigned int cmd, unsigned long arg) { - struct cdrom_generic_command cgc; + struct packet_command cgc; char buffer[16]; int stat; @@ -2535,7 +2469,7 @@ int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, case CDROMSETSPINDOWN: { char spindown; - if (copy_from_user(&spindown, (void *) arg, sizeof(char))) + if (copy_from_user(&spindown, (void __user *) arg, sizeof(char))) return -EFAULT; if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) @@ -2554,7 +2488,7 @@ int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, spindown = buffer[11] & 0x0f; - if (copy_to_user((void *) arg, &spindown, sizeof (char))) + if (copy_to_user((void __user *) arg, &spindown, sizeof (char))) return -EFAULT; return 0; @@ -2725,8 +2659,10 @@ int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr) if (!cdrom_get_media_event(cdi, &med)) { if (med.media_present) return CDS_DISC_OK; - if (med.door_open) + else if (med.door_open) return CDS_TRAY_OPEN; + else + return CDS_NO_DISC; } if (sense.sense_key == NOT_READY && sense.asc == 0x04 && sense.ascq == 0x04) @@ -2738,10 +2674,12 @@ int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr) * any other way to detect this... */ if (sense.sense_key == NOT_READY) { - if (sense.asc == 0x3a && sense.ascq == 1) - return CDS_NO_DISC; - else - return CDS_TRAY_OPEN; + if (sense.asc == 0x3a) { + if (sense.ascq == 1) + return CDS_NO_DISC; + else if (sense.ascq == 0 || sense.ascq == 2) + return CDS_TRAY_OPEN; + } } return CDS_DRIVE_NOT_READY; @@ -2818,7 +2756,6 @@ int ide_cdrom_open_real (struct cdrom_device_info *cdi, int purpose) return 0; } - /* * Close down the device. Invalidate all cached blocks. */ @@ -2892,12 +2829,6 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots) devinfo->mask |= CDC_CLOSE_TRAY; if (!CDROM_CONFIG_FLAGS(drive)->mo_drive) devinfo->mask |= CDC_MO_DRIVE; - if (!CDROM_CONFIG_FLAGS(drive)->mrw) - devinfo->mask |= CDC_MRW; - if (!CDROM_CONFIG_FLAGS(drive)->mrw_w) - devinfo->mask |= CDC_MRW_W; - if (!CDROM_CONFIG_FLAGS(drive)->ram) - devinfo->mask |= CDC_RAM; devinfo->disk = drive->disk; return register_cdrom(devinfo); @@ -2908,7 +2839,7 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_pag { struct cdrom_info *info = drive->driver_data; struct cdrom_device_info *cdi = &info->devinfo; - struct cdrom_generic_command cgc; + struct packet_command cgc; int stat, attempts = 3, size = sizeof(*cap); /* @@ -2934,12 +2865,12 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) struct cdrom_info *info = drive->driver_data; struct cdrom_device_info *cdi = &info->devinfo; struct atapi_capabilities_page cap; - int nslots = 1, mrw_write = 0, ram_write = 0; + int nslots = 1; 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; } @@ -2963,25 +2894,16 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) if (ide_cdrom_get_capabilities(drive, &cap)) return 0; - if (!cdrom_is_mrw(cdi, &mrw_write)) { - CDROM_CONFIG_FLAGS(drive)->mrw = 1; - if (mrw_write) { - CDROM_CONFIG_FLAGS(drive)->mrw_w = 1; - CDROM_CONFIG_FLAGS(drive)->ram = 1; - } - } - if (!cdrom_is_random_writable(cdi, &ram_write)) - if (ram_write) - CDROM_CONFIG_FLAGS(drive)->ram = 1; - if (cap.lock == 0) CDROM_CONFIG_FLAGS(drive)->no_doorlock = 1; if (cap.eject) 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) @@ -3038,7 +2960,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) /* 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"); @@ -3053,9 +2975,6 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) (CDROM_CONFIG_FLAGS(drive)->cd_r)? "-R" : "", (CDROM_CONFIG_FLAGS(drive)->cd_rw)? "/RW" : ""); - if (CDROM_CONFIG_FLAGS(drive)->mrw || CDROM_CONFIG_FLAGS(drive)->mrw_w) - printk(" CD-MR%s", CDROM_CONFIG_FLAGS(drive)->mrw_w ? "W" : ""); - if (CDROM_CONFIG_FLAGS(drive)->is_changer) printk(" changer w/%d slots", nslots); else @@ -3063,10 +2982,9 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) 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; @@ -3164,7 +3082,7 @@ int ide_cdrom_setup (ide_drive_t *drive) int nslots; blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); - blk_queue_dma_alignment(drive->queue, 3); + blk_queue_dma_alignment(drive->queue, 31); drive->queue->unplug_delay = (1 * HZ) / 1000; if (!drive->queue->unplug_delay) drive->queue->unplug_delay = 1; @@ -3271,9 +3189,8 @@ int ide_cdrom_setup (ide_drive_t *drive) nslots = ide_cdrom_probe_capabilities (drive); /* - * set correct block size and read-only for non-ram media + * set correct block size */ - set_disk_ro(drive->disk, !CDROM_CONFIG_FLAGS(drive)->ram); blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); #if 0 @@ -3286,7 +3203,7 @@ int ide_cdrom_setup (ide_drive_t *drive) #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; } @@ -3313,7 +3230,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive) 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; } @@ -3324,7 +3241,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive) 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); @@ -3383,9 +3300,6 @@ static ide_driver_t ide_cdrom_driver = { .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), @@ -3423,10 +3337,10 @@ static int idecd_ioctl (struct inode *inode, struct file *file, { struct block_device *bdev = inode->i_bdev; ide_drive_t *drive = bdev->bd_disk->private_data; - int err = generic_ide_ioctl(bdev, cmd, arg); + int err = generic_ide_ioctl(file, bdev, cmd, arg); if (err == -EINVAL) { struct cdrom_info *info = drive->driver_data; - err = cdrom_ioctl(&info->devinfo, inode, cmd, arg); + err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); } return err; } @@ -3456,9 +3370,9 @@ static struct block_device_operations idecd_ops = { }; /* 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) @@ -3476,21 +3390,21 @@ 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; @@ -3514,7 +3428,7 @@ static int ide_cdrom_attach (ide_drive_t *drive) 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;