• Home
  • Raw
  • Download

Lines Matching full:drive

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