Lines Matching refs:drive
67 if (ide_device_get(cd->drive))
79 ide_drive_t *drive = cd->drive;
83 ide_device_put(drive);
92 static void cdrom_saw_media_change(ide_drive_t *drive)
94 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
95 drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID;
98 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq)
100 struct request_sense *sense = &drive->sense_data;
124 * reliably check if drive can auto-close
136 cdrom_saw_media_change(drive);
145 static void cdrom_analyze_sense_data(ide_drive_t *drive,
148 struct request_sense *sense = &drive->sense_data;
149 struct cdrom_info *info = drive->driver_data;
160 if (!cdrom_log_sense(drive, failed_command))
188 if (queue_logical_block_size(drive->queue) == 2048)
204 drive->probed_capacity - sector < 4 * 75)
209 ide_cd_log_error(drive->name, failed_command, sense);
212 static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
225 * Sense is always read into drive->sense_data, copy back to the
230 cdrom_analyze_sense_data(drive, failed);
232 if (ide_end_rq(drive, failed, BLK_STS_IOERR, blk_rq_bytes(failed)))
235 cdrom_analyze_sense_data(drive, NULL);
240 * Allow the drive 5 seconds to recover; some devices will return NOT_READY
246 static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
249 struct cdrom_info *info = drive->driver_data;
263 blk_mq_delay_kick_requeue_list(drive->queue, 1);
268 static void ide_cd_free_sense(ide_drive_t *drive)
270 if (!drive->sense_rq)
273 blk_mq_free_request(drive->sense_rq);
274 drive->sense_rq = NULL;
275 drive->sense_rq_armed = false;
284 static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
286 ide_hwif_t *hwif = drive->hwif;
291 err = ide_read_error(drive);
300 * We got an error trying to get sense info from the drive
318 if (ide_cd_breathe(drive, rq))
321 cdrom_saw_media_change(drive);
326 drive->name);
331 cdrom_saw_media_change(drive);
347 * to close the tray if the drive doesn't have that capability.
360 ide_dump_status(drive, "command error", stat);
369 ide_dump_status(drive, "media error "
376 ide_dump_status(drive, "media error (blank)",
385 ide_error(drive, "cdrom_decode_status", stat);
406 return ide_queue_sense_rq(drive, NULL) ? 2 : 1;
412 return ide_queue_sense_rq(drive, rq) ? 2 : 1;
417 static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd)
432 int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
437 struct cdrom_info *info = drive->driver_data;
455 rq = blk_get_request(drive->queue,
462 error = blk_rq_map_kern(drive->queue, rq, buffer,
470 blk_execute_rq(drive->queue, info->disk, rq, 0);
489 cdrom_saw_media_change(drive);
493 * The drive is in the process of loading
495 * the drive time to complete the load.
516 static bool ide_cd_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd)
524 ide_complete_rq(drive, BLK_STS_OK, nr_bytes);
595 static bool ide_cdrom_prep_rq(ide_drive_t *drive, struct request *rq)
600 return ide_cdrom_prep_fs(drive->queue, rq);
607 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
609 ide_hwif_t *hwif = drive->hwif;
623 dma = drive->dma;
625 drive->dma = 0;
626 drive->waiting_for_dma = 0;
627 dma_error = hwif->dma_ops->dma_end(drive);
628 ide_dma_unmap_sg(drive, cmd);
630 printk(KERN_ERR PFX "%s: DMA %s error\n", drive->name,
632 ide_dma_off(drive);
640 rc = cdrom_decode_status(drive, stat);
651 return ide_error(drive, "dma error", stat);
656 ide_read_bcount_and_ireason(drive, &len, &ireason);
676 "(%u bytes)\n", drive->name, __func__,
685 ide_cd_request_sense_fixup(drive, cmd);
690 * suck out the remaining bytes from the drive in an
694 ide_pio_bytes(drive, cmd, write, thislen);
707 rc = ide_check_ireason(drive, rq, len, ireason, write);
724 ide_pio_bytes(drive, cmd, write, blen);
737 ide_pad_transfer(drive, write, len);
740 drive->name);
760 ide_set_handler(drive, cdrom_newpc_intr, timeout);
770 ide_cd_complete_failed_rq(drive, rq);
781 if (ide_cd_error_cmd(drive, cmd))
791 ide_complete_rq(drive, uptodate ? BLK_STS_OK : BLK_STS_IOERR, blk_rq_bytes(rq));
794 ide_error(drive, "request sense failure", stat);
797 ide_cd_free_sense(drive);
801 static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
803 struct cdrom_info *cd = drive->driver_data;
804 struct request_queue *q = drive->queue;
822 ide_cdrom_prep_rq(drive, rq);
831 drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
841 static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
852 drive->dma = 0;
856 struct request_queue *q = drive->queue;
860 drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
872 drive->dma = 0;
876 static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
886 if (drive->debug_mask & IDE_DBG_RQ)
891 if (cdrom_start_rw(drive, rq) == ide_stopped)
899 cdrom_do_block_pc(drive, rq);
917 ide_prep_sense(drive, rq);
928 ide_map_sg(drive, &cmd);
931 return ide_issue_pc(drive, &cmd);
938 ide_complete_rq(drive, uptodate ? BLK_STS_OK : BLK_STS_IOERR, nsectors << 9);
959 int cdrom_check_status(ide_drive_t *drive, struct scsi_sense_hdr *sshdr)
961 struct cdrom_info *info = drive->driver_data;
981 return ide_cd_queue_pc(drive, cmd, 0, NULL, NULL, sshdr, 0, RQF_QUIET);
984 static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1002 stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, NULL, 0,
1023 drive->name, blocklen);
1037 static int ide_cdrom_read_tocentry(ide_drive_t *drive, int trackno,
1055 return ide_cd_queue_pc(drive, cmd, 0, buf, &buflen, NULL, 0, RQF_QUIET);
1059 int ide_cd_read_toc(ide_drive_t *drive)
1062 struct cdrom_info *info = drive->driver_data;
1079 drive->name);
1089 (void) cdrom_check_status(drive, NULL);
1091 if (drive->atapi_flags & IDE_AFLAG_TOC_VALID)
1095 stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame);
1101 drive->probed_capacity = toc->capacity * sectors_per_frame;
1103 blk_queue_logical_block_size(drive->queue,
1107 stat = ide_cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
1112 if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
1124 stat = ide_cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0,
1144 stat = ide_cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0,
1152 if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
1166 if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD) {
1172 if (drive->atapi_flags & IDE_AFLAG_TOCADDR_AS_BCD) {
1173 if (drive->atapi_flags & IDE_AFLAG_TOCTRACKS_AS_BCD)
1184 stat = ide_cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,
1196 if (drive->atapi_flags & IDE_AFLAG_TOCADDR_AS_BCD) {
1198 stat = ide_cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp,
1216 drive->probed_capacity = toc->capacity * sectors_per_frame;
1220 drive->atapi_flags |= IDE_AFLAG_TOC_VALID;
1225 int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf)
1227 struct cdrom_info *info = drive->driver_data;
1234 if ((drive->atapi_flags & IDE_AFLAG_FULL_CAPS_PAGE) == 0)
1247 void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
1249 struct cdrom_info *cd = drive->driver_data;
1254 if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) {
1292 static int ide_cdrom_register(ide_drive_t *drive, int nslots)
1294 struct cdrom_info *info = drive->driver_data;
1302 devinfo->handle = drive;
1303 strcpy(devinfo->name, drive->name);
1305 if (drive->atapi_flags & IDE_AFLAG_NO_SPEED_SELECT)
1311 static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1313 struct cdrom_info *cd = drive->driver_data;
1320 drive->media, drive->atapi_flags);
1326 if (drive->media == ide_optical) {
1328 printk(KERN_ERR PFX "%s: ATAPI magneto-optical drive\n",
1329 drive->name);
1333 if (drive->atapi_flags & IDE_AFLAG_PRE_ATAPI12) {
1334 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT;
1341 * with ide_cdrom_packet(), which extracts the drive from cdi->handle.
1345 cdi->handle = drive;
1348 if (ide_cdrom_get_capabilities(drive, buf))
1352 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
1354 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT;
1365 if ((buf[8 + 4] & 0x01) || (drive->atapi_flags & IDE_AFLAG_PLAY_AUDIO_OK))
1371 (drive->atapi_flags & IDE_AFLAG_NO_AUTOCLOSE))
1384 ide_cdrom_update_speed(drive, buf);
1386 printk(KERN_INFO PFX "%s: ATAPI", drive->name);
1388 /* don't print speed if the drive reported 0 */
1407 printk(KERN_CONT " drive");
1422 static sector_t ide_cdrom_capacity(ide_drive_t *drive)
1426 if (cdrom_read_capacity(drive, &capacity, §ors_per_frame))
1434 ide_drive_t *drive = m->private;
1436 seq_printf(m, "%llu\n", (long long)ide_cdrom_capacity(drive));
1445 static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
1450 static const struct ide_proc_devset *ide_cd_proc_devsets(ide_drive_t *drive)
1462 /* Vertos 300, some versions of this drive like to talk BCD. */
1513 static int ide_cdrom_setup(ide_drive_t *drive)
1515 struct cdrom_info *cd = drive->driver_data;
1517 struct request_queue *q = drive->queue;
1518 u16 *id = drive->id;
1524 drive->prep_rq = ide_cdrom_prep_rq;
1528 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
1529 drive->atapi_flags = IDE_AFLAG_NO_EJECT | ide_cd_flags(id);
1531 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) &&
1533 drive->atapi_flags |= (IDE_AFLAG_TOCTRACKS_AS_BCD |
1535 else if ((drive->atapi_flags & IDE_AFLAG_VERTOS_600_ESD) &&
1537 drive->atapi_flags |= IDE_AFLAG_TOCTRACKS_AS_BCD;
1538 else if (drive->atapi_flags & IDE_AFLAG_SANYO_3CD)
1542 nslots = ide_cdrom_probe_capabilities(drive);
1546 if (ide_cdrom_register(drive, nslots)) {
1548 " cdrom driver.\n", drive->name, __func__);
1553 ide_proc_register_driver(drive, cd->driver);
1557 static void ide_cd_remove(ide_drive_t *drive)
1559 struct cdrom_info *info = drive->driver_data;
1563 ide_proc_unregister_driver(drive, info->driver);
1576 ide_drive_t *drive = info->drive;
1582 if (devinfo->handle == drive)
1584 drive->driver_data = NULL;
1585 drive->prep_rq = NULL;
1617 ide_cd_read_toc(info->drive);
1698 err = generic_ide_ioctl(info->drive, bdev, cmd, arg);
1733 err = generic_ide_ioctl(info->drive, bdev, cmd, arg);
1776 static int ide_cd_probe(ide_drive_t *drive)
1782 drive->driver_req, drive->media);
1784 if (!strstr("ide-cdrom", drive->driver_req))
1787 if (drive->media != ide_cdrom && drive->media != ide_optical)
1790 drive->debug_mask = debug_mask;
1791 drive->irq_handler = cdrom_newpc_intr;
1796 drive->name);
1804 ide_init_disk(g, drive);
1806 info->dev.parent = &drive->gendev;
1808 dev_set_name(&info->dev, "%s", dev_name(&drive->gendev));
1813 info->drive = drive;
1819 drive->driver_data = info;
1823 if (ide_cdrom_setup(drive)) {
1828 ide_cd_read_toc(drive);
1832 device_add_disk(&drive->gendev, g, NULL);