• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/ide/

Lines Matching defs:drive

55 static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)
67 if (drive->mult_count) {
81 static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
84 ide_hwif_t *hwif = drive->hwif;
86 u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48);
87 u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
103 if (drive->dev_flags & IDE_DFLAG_LBA) {
105 pr_debug("%s: LBA=0x%012llx\n", drive->name,
135 track = (int)block / drive->sect;
136 sect = (int)block % drive->sect + 1;
137 head = track % drive->head;
138 cyl = track / drive->head;
140 pr_debug("%s: CHS=%u/%u/%u\n", drive->name, cyl, head, sect);
154 ide_tf_set_cmd(drive, &cmd, dma);
159 ide_map_sg(drive, &cmd);
162 rc = do_rw_taskfile(drive, &cmd);
167 ide_tf_set_cmd(drive, &cmd, 0);
169 rc = do_rw_taskfile(drive, &cmd);
178 * 1073741822 == 549756 MB or 48bit addressing fake drive
181 static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
184 ide_hwif_t *hwif = drive->hwif;
186 BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
192 drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
197 hwif->rw_disk(drive, rq);
199 return __ide_do_rw_disk(drive, rq, block);
203 * Queries for true maximum capacity of the drive.
204 * Returns maximum LBA address (> 0) of the drive, 0 if failed.
206 static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48)
227 ide_no_data_taskfile(drive, &cmd);
237 * Sets maximum virtual LBA address of the drive.
240 static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48)
271 ide_no_data_taskfile(drive, &cmd);
298 static u64 ide_disk_hpa_get_native_capacity(ide_drive_t *drive, int lba48)
302 capacity = drive->capacity64;
303 set_max = idedisk_read_native_max_address(drive, lba48);
305 if (ide_in_drive_list(drive->id, hpa_list)) {
313 static u64 ide_disk_hpa_set_capacity(ide_drive_t *drive, u64 set_max, int lba48)
315 set_max = idedisk_set_max_address(drive, set_max, lba48);
317 drive->capacity64 = set_max;
322 static void idedisk_check_hpa(ide_drive_t *drive)
325 int lba48 = ata_id_lba48_enabled(drive->id);
327 capacity = drive->capacity64;
328 set_max = ide_disk_hpa_get_native_capacity(drive, lba48);
333 drive->probed_capacity = set_max;
338 drive->name,
342 if ((drive->dev_flags & IDE_DFLAG_NOHPA) == 0)
345 set_max = ide_disk_hpa_set_capacity(drive, set_max, lba48);
348 drive->name);
351 static int ide_disk_get_capacity(ide_drive_t *drive)
353 u16 *id = drive->id;
357 /* drive speaks 48-bit LBA */
359 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
361 /* drive speaks 28-bit LBA */
363 drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
365 /* drive speaks boring old 28-bit CHS */
367 drive->capacity64 = drive->cyl * drive->head * drive->sect;
370 drive->probed_capacity = drive->capacity64;
373 drive->dev_flags |= IDE_DFLAG_LBA;
380 idedisk_check_hpa(drive);
383 /* limit drive capacity to 137GB if LBA48 cannot be used */
384 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
385 drive->capacity64 > 1ULL << 28) {
388 drive->name, (unsigned long long)drive->capacity64,
389 sectors_to_MB(drive->capacity64));
390 drive->probed_capacity = drive->capacity64 = 1ULL << 28;
393 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
394 (drive->dev_flags & IDE_DFLAG_LBA48)) {
395 if (drive->capacity64 > 1ULL << 28) {
398 "> %u\n", drive->name, 1 << 28);
400 drive->dev_flags &= ~IDE_DFLAG_LBA48;
406 static void ide_disk_unlock_native_capacity(ide_drive_t *drive)
408 u16 *id = drive->id;
411 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
419 if (!ide_disk_hpa_get_native_capacity(drive, lba48))
422 if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48))
423 drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */
428 ide_drive_t *drive = q->queuedata;
439 if (ata_id_flush_ext_enabled(drive->id) &&
440 (drive->capacity64 >= (1UL << 28)))
461 static int set_multcount(ide_drive_t *drive, int arg)
466 if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff))
469 if (drive->special_flags & IDE_SFLAG_SET_MULTMODE)
472 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
475 drive->mult_req = arg;
476 drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
477 error = blk_execute_rq(drive->queue, NULL, rq, 0);
480 return (drive->mult_count == arg) ? 0 : -EIO;
485 static int set_nowerr(ide_drive_t *drive, int arg)
491 drive->dev_flags |= IDE_DFLAG_NOWERR;
493 drive->dev_flags &= ~IDE_DFLAG_NOWERR;
495 drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT;
500 static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect)
511 return ide_no_data_taskfile(drive, &cmd);
514 static void update_ordered(ide_drive_t *drive)
516 u16 *id = drive->id;
519 if (drive->dev_flags & IDE_DFLAG_WCACHE) {
523 * We must avoid issuing commands a drive does not
526 * cache if the drive capacity is too large. By this
527 * time we have trimmed the drive capacity if LBA48 is
530 capacity = ide_gd_capacity(drive);
532 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 &&
533 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 ||
538 drive->name, barrier ? "" : "not ");
542 blk_queue_prep_rq(drive->queue, idedisk_prep_fn);
547 blk_queue_ordered(drive->queue, ordered);
552 static int set_wcache(ide_drive_t *drive, int arg)
559 if (ata_id_flush_enabled(drive->id)) {
560 err = ide_do_setfeature(drive,
564 drive->dev_flags |= IDE_DFLAG_WCACHE;
566 drive->dev_flags &= ~IDE_DFLAG_WCACHE;
570 update_ordered(drive);
575 static int do_idedisk_flushcache(ide_drive_t *drive)
580 if (ata_id_flush_ext_enabled(drive->id))
587 return ide_no_data_taskfile(drive, &cmd);
592 static int set_acoustic(ide_drive_t *drive, int arg)
597 ide_do_setfeature(drive,
600 drive->acoustic = arg;
608 * drive->addressing:
613 static int set_addressing(ide_drive_t *drive, int arg)
618 if (arg && ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) ||
619 ata_id_lba48_enabled(drive->id) == 0))
626 drive->dev_flags |= IDE_DFLAG_LBA48;
628 drive->dev_flags &= ~IDE_DFLAG_LBA48;
640 static int ide_disk_check(ide_drive_t *drive, const char *s)
645 static void ide_disk_setup(ide_drive_t *drive)
647 struct ide_disk_obj *idkp = drive->driver_data;
648 struct request_queue *q = drive->queue;
649 ide_hwif_t *hwif = drive->hwif;
650 u16 *id = drive->id;
654 ide_proc_register_driver(drive, idkp->driver);
656 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0)
659 if (drive->dev_flags & IDE_DFLAG_REMOVABLE) {
664 drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
667 (void)set_addressing(drive, 1);
669 if (drive->dev_flags & IDE_DFLAG_LBA48) {
678 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
684 /* calculate drive capacity, and select LBA if possible */
685 ide_disk_get_capacity(drive);
688 * if possible, give fdisk access to more of the drive,
691 capacity = ide_gd_capacity(drive);
693 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) {
694 if (ata_id_lba48_enabled(drive->id)) {
696 drive->bios_sect = 63;
697 drive->bios_head = 255;
700 if (drive->bios_sect && drive->bios_head) {
705 drive->bios_cyl = 65535;
707 cylsz = drive->bios_sect * drive->bios_head;
711 if (cyl > drive->bios_cyl)
712 drive->bios_cyl = cyl;
717 drive->name, capacity, sectors_to_MB(capacity));
724 drive->bios_cyl, drive->bios_head, drive->bios_sect);
728 drive->dev_flags |= IDE_DFLAG_WCACHE;
730 set_wcache(drive, 1);
732 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
733 (drive->head == 0 || drive->head > 16)) {
735 drive->name, drive->head);
736 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
738 drive->dev_flags |= IDE_DFLAG_ATTACH;
741 static void ide_disk_flush(ide_drive_t *drive)
743 if (ata_id_flush_enabled(drive->id) == 0 ||
744 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0)
747 if (do_idedisk_flushcache(drive))
748 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
751 static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk)
756 static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
762 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
770 ret = ide_no_data_taskfile(drive, &cmd);
773 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;