Lines Matching refs:drive
51 static void generic_id(ide_drive_t *drive) in generic_id() argument
53 u16 *id = drive->id; in generic_id()
55 id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl; in generic_id()
56 id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head; in generic_id()
57 id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect; in generic_id()
60 static void ide_disk_init_chs(ide_drive_t *drive) in ide_disk_init_chs() argument
62 u16 *id = drive->id; in ide_disk_init_chs()
65 if (!drive->cyl || !drive->head || !drive->sect) { in ide_disk_init_chs()
66 drive->cyl = drive->bios_cyl = id[ATA_ID_CYLS]; in ide_disk_init_chs()
67 drive->head = drive->bios_head = id[ATA_ID_HEADS]; in ide_disk_init_chs()
68 drive->sect = drive->bios_sect = id[ATA_ID_SECTORS]; in ide_disk_init_chs()
73 drive->cyl = id[ATA_ID_CUR_CYLS]; in ide_disk_init_chs()
74 drive->head = id[ATA_ID_CUR_HEADS]; in ide_disk_init_chs()
75 drive->sect = id[ATA_ID_CUR_SECTORS]; in ide_disk_init_chs()
79 if (drive->head > 16 && id[ATA_ID_HEADS] && id[ATA_ID_HEADS] <= 16) { in ide_disk_init_chs()
80 drive->cyl = id[ATA_ID_CYLS]; in ide_disk_init_chs()
81 drive->head = id[ATA_ID_HEADS]; in ide_disk_init_chs()
82 drive->sect = id[ATA_ID_SECTORS]; in ide_disk_init_chs()
86 static void ide_disk_init_mult_count(ide_drive_t *drive) in ide_disk_init_mult_count() argument
88 u16 *id = drive->id; in ide_disk_init_mult_count()
97 drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; in ide_disk_init_mult_count()
99 if (drive->mult_req) in ide_disk_init_mult_count()
100 drive->special_flags |= IDE_SFLAG_SET_MULTMODE; in ide_disk_init_mult_count()
104 static void ide_classify_ata_dev(ide_drive_t *drive) in ide_classify_ata_dev() argument
106 u16 *id = drive->id; in ide_classify_ata_dev()
112 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_ata_dev()
114 drive->media = ide_disk; in ide_classify_ata_dev()
116 if (!ata_id_has_unload(drive->id)) in ide_classify_ata_dev()
117 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; in ide_classify_ata_dev()
119 printk(KERN_INFO "%s: %s, %s DISK drive\n", drive->name, m, in ide_classify_ata_dev()
123 static void ide_classify_atapi_dev(ide_drive_t *drive) in ide_classify_atapi_dev() argument
125 u16 *id = drive->id; in ide_classify_atapi_dev()
129 printk(KERN_INFO "%s: %s, ATAPI ", drive->name, m); in ide_classify_atapi_dev()
137 if (drive->media != ide_cdrom) { in ide_classify_atapi_dev()
139 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
146 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
162 drive->dev_flags |= IDE_DFLAG_REMOVABLE; in ide_classify_atapi_dev()
170 drive->media = type; in ide_classify_atapi_dev()
172 drive->ready_stat = 0; in ide_classify_atapi_dev()
174 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; in ide_classify_atapi_dev()
175 drive->dev_flags |= IDE_DFLAG_DOORLOCKING; in ide_classify_atapi_dev()
177 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; in ide_classify_atapi_dev()
191 static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id) in do_identify() argument
193 ide_hwif_t *hwif = drive->hwif; in do_identify()
201 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); in do_identify()
204 drive->dev_flags |= IDE_DFLAG_ID_READ; in do_identify()
206 printk(KERN_INFO "%s: dumping identify data\n", drive->name); in do_identify()
231 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in do_identify()
233 drive->dev_flags |= IDE_DFLAG_PRESENT; in do_identify()
250 int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id, int irq_ctx) in ide_dev_read_id() argument
252 ide_hwif_t *hwif = drive->hwif; in ide_dev_read_id()
280 drive->name, s, a); in ide_dev_read_id()
294 tp_ops->tf_load(drive, &tf, IDE_VALID_FEATURE); in ide_dev_read_id()
304 rc = __ide_wait_stat(drive, ATA_DRQ, BAD_R_STAT, timeout, &s); in ide_dev_read_id()
308 rc = ide_busy_sleep(drive, timeout, use_altstatus); in ide_dev_read_id()
318 do_identify(drive, cmd, id); in ide_dev_read_id()
330 int ide_busy_sleep(ide_drive_t *drive, unsigned long timeout, int altstatus) in ide_busy_sleep() argument
332 ide_hwif_t *hwif = drive->hwif; in ide_busy_sleep()
345 printk(KERN_ERR "%s: timeout in %s\n", drive->name, __func__); in ide_busy_sleep()
350 static u8 ide_read_device(ide_drive_t *drive) in ide_read_device() argument
354 drive->hwif->tp_ops->tf_read(drive, &tf, IDE_VALID_DEVICE); in ide_read_device()
380 static int do_probe (ide_drive_t *drive, u8 cmd) in do_probe() argument
382 ide_hwif_t *hwif = drive->hwif; in do_probe()
384 u16 *id = drive->id; in do_probe()
386 u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; in do_probe()
389 if (present && drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) in do_probe()
394 drive->name, present, drive->media, in do_probe()
402 tp_ops->dev_select(drive); in do_probe()
405 if (ide_read_device(drive) != drive->select && present == 0) { in do_probe()
406 if (drive->dn & 1) { in do_probe()
420 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
423 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
432 "resetting drive\n", drive->name, stat); in do_probe()
434 tp_ops->dev_select(drive); in do_probe()
437 (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0); in do_probe()
438 rc = ide_dev_read_id(drive, cmd, id, 0); in do_probe()
446 drive->name, stat); in do_probe()
451 if (drive->dn & 1) { in do_probe()
473 static u8 probe_for_drive(ide_drive_t *drive) in probe_for_drive() argument
479 drive->dev_flags &= ~IDE_DFLAG_ID_READ; in probe_for_drive()
481 m = (char *)&drive->id[ATA_ID_PROD]; in probe_for_drive()
485 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { in probe_for_drive()
488 rc = do_probe(drive, cmd); in probe_for_drive()
492 rc = do_probe(drive, cmd); in probe_for_drive()
495 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in probe_for_drive()
499 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { in probe_for_drive()
500 if (drive->media == ide_disk) { in probe_for_drive()
502 drive->name, drive->cyl, in probe_for_drive()
503 drive->head, drive->sect); in probe_for_drive()
504 } else if (drive->media == ide_cdrom) { in probe_for_drive()
505 printk(KERN_INFO "%s: ATAPI cdrom (?)\n", drive->name); in probe_for_drive()
508 … printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); in probe_for_drive()
509 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in probe_for_drive()
513 ide_classify_atapi_dev(drive); in probe_for_drive()
515 ide_classify_ata_dev(drive); in probe_for_drive()
519 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in probe_for_drive()
523 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { in probe_for_drive()
524 generic_id(drive); in probe_for_drive()
528 if (drive->media == ide_disk) { in probe_for_drive()
529 ide_disk_init_chs(drive); in probe_for_drive()
530 ide_disk_init_mult_count(drive); in probe_for_drive()
600 ide_drive_t *drive; in ide_port_wait_ready() local
618 ide_port_for_each_dev(i, drive, hwif) { in ide_port_wait_ready()
620 if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || in ide_port_wait_ready()
621 (drive->dev_flags & IDE_DFLAG_PRESENT)) { in ide_port_wait_ready()
622 tp_ops->dev_select(drive); in ide_port_wait_ready()
630 drive->name); in ide_port_wait_ready()
680 ide_drive_t *drive; in ide_probe_port() local
705 ide_port_for_each_dev(i, drive, hwif) { in ide_probe_port()
706 (void) probe_for_drive(drive); in ide_probe_port()
707 if (drive->dev_flags & IDE_DFLAG_PRESENT) in ide_probe_port()
724 ide_drive_t *drive; in ide_port_tune_devices() local
727 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
728 ide_check_nien_quirk_list(drive); in ide_port_tune_devices()
731 port_ops->quirkproc(drive); in ide_port_tune_devices()
734 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_tune_devices()
735 ide_set_max_pio(drive); in ide_port_tune_devices()
737 drive->dev_flags |= IDE_DFLAG_NICE1; in ide_port_tune_devices()
740 ide_set_dma(drive); in ide_port_tune_devices()
747 static int ide_init_queue(ide_drive_t *drive) in ide_init_queue() argument
750 ide_hwif_t *hwif = drive->hwif; in ide_init_queue()
766 q->queuedata = drive; in ide_init_queue()
790 drive->queue = q; in ide_init_queue()
793 ide_toggle_bounce(drive, 1); in ide_init_queue()
806 ide_drive_t *drive; in ide_port_setup_devices() local
810 ide_port_for_each_present_dev(i, drive, hwif) { in ide_port_setup_devices()
811 if (ide_init_queue(drive)) { in ide_port_setup_devices()
813 drive->name); in ide_port_setup_devices()
814 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in ide_port_setup_devices()
887 ide_drive_t *drive = hwif->devices[unit]; in ata_probe() local
889 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) in ata_probe()
892 if (drive->media == ide_disk) in ata_probe()
894 if (drive->media == ide_cdrom || drive->media == ide_optical) in ata_probe()
896 if (drive->media == ide_tape) in ata_probe()
898 if (drive->media == ide_floppy) in ata_probe()
936 void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) in ide_init_disk() argument
938 ide_hwif_t *hwif = drive->hwif; in ide_init_disk()
939 unsigned int unit = drive->dn & 1; in ide_init_disk()
944 disk->queue = drive->queue; in ide_init_disk()
951 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); in drive_release_dev() local
953 ide_proc_unregister_device(drive); in drive_release_dev()
955 blk_cleanup_queue(drive->queue); in drive_release_dev()
956 drive->queue = NULL; in drive_release_dev()
958 drive->dev_flags &= ~IDE_DFLAG_PRESENT; in drive_release_dev()
960 complete(&drive->gendev_rel_comp); in drive_release_dev()
1002 ide_drive_t *drive; in hwif_register_devices() local
1005 ide_port_for_each_present_dev(i, drive, hwif) { in hwif_register_devices()
1006 struct device *dev = &drive->gendev; in hwif_register_devices()
1010 dev_set_drvdata(dev, drive); in hwif_register_devices()
1025 ide_drive_t *drive; in ide_port_init_devices() local
1028 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices()
1029 drive->dn = i + hwif->channel * 2; in ide_port_init_devices()
1032 drive->io_32bit = 1; in ide_port_init_devices()
1034 drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; in ide_port_init_devices()
1036 drive->dev_flags |= IDE_DFLAG_UNMASK; in ide_port_init_devices()
1038 drive->dev_flags |= IDE_DFLAG_NO_UNMASK; in ide_port_init_devices()
1040 drive->pio_mode = XFER_PIO_0; in ide_port_init_devices()
1043 port_ops->init_dev(drive); in ide_port_init_devices()
1128 ide_drive_t *drive; in ide_port_init_devices_data() local
1131 ide_port_for_each_dev(i, drive, hwif) { in ide_port_init_devices_data()
1133 u16 *saved_id = drive->id; in ide_port_init_devices_data()
1135 memset(drive, 0, sizeof(*drive)); in ide_port_init_devices_data()
1137 drive->id = saved_id; in ide_port_init_devices_data()
1139 drive->media = ide_disk; in ide_port_init_devices_data()
1140 drive->select = (i << 4) | ATA_DEVICE_OBS; in ide_port_init_devices_data()
1141 drive->hwif = hwif; in ide_port_init_devices_data()
1142 drive->ready_stat = ATA_DRDY; in ide_port_init_devices_data()
1143 drive->bad_wstat = BAD_W_STAT; in ide_port_init_devices_data()
1144 drive->special_flags = IDE_SFLAG_RECALIBRATE | in ide_port_init_devices_data()
1146 drive->name[0] = 'h'; in ide_port_init_devices_data()
1147 drive->name[1] = 'd'; in ide_port_init_devices_data()
1148 drive->name[2] = 'a' + j; in ide_port_init_devices_data()
1149 drive->max_failures = IDE_DEFAULT_MAX_FAILURES; in ide_port_init_devices_data()
1151 INIT_LIST_HEAD(&drive->list); in ide_port_init_devices_data()
1152 init_completion(&drive->gendev_rel_comp); in ide_port_init_devices_data()
1240 ide_drive_t *drive; in ide_port_free_devices() local
1243 ide_port_for_each_dev(i, drive, hwif) { in ide_port_free_devices()
1244 kfree(drive->id); in ide_port_free_devices()
1245 kfree(drive); in ide_port_free_devices()
1254 ide_drive_t *drive; in ide_port_alloc_devices() local
1256 drive = kzalloc_node(sizeof(*drive), GFP_KERNEL, node); in ide_port_alloc_devices()
1257 if (drive == NULL) in ide_port_alloc_devices()
1268 drive->id = kzalloc_node(SECTOR_SIZE, GFP_KERNEL, node); in ide_port_alloc_devices()
1269 if (drive->id == NULL) in ide_port_alloc_devices()
1272 hwif->devices[i] = drive; in ide_port_alloc_devices()
1490 ide_drive_t *drive; in __ide_port_unregister_devices() local
1493 ide_port_for_each_present_dev(i, drive, hwif) { in __ide_port_unregister_devices()
1494 device_unregister(&drive->gendev); in __ide_port_unregister_devices()
1495 wait_for_completion(&drive->gendev_rel_comp); in __ide_port_unregister_devices()