diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:36 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:36 -0400 |
commit | 97100fc816badbbc162644cfde7ad39ae9211fb4 (patch) | |
tree | 904faf5453c2dea32fa3fde5fda230118f3effda /drivers/ide/ide-disk.c | |
parent | be3c096ebdbe3c828aacb5473751a22840753eff (diff) |
ide: add device flags
Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields
to IDE_DFLAG_* flags.
While at it:
- IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48
- fixup some comments
- remove needless g->flags zeroing from ide*_probe()
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 94 |
1 files changed, 57 insertions, 37 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 7ea075299bd9..7ee2c9d2e5c2 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -140,9 +140,9 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
140 | sector_t block) | 140 | sector_t block) |
141 | { | 141 | { |
142 | ide_hwif_t *hwif = HWIF(drive); | 142 | ide_hwif_t *hwif = HWIF(drive); |
143 | unsigned int dma = drive->using_dma; | ||
144 | u16 nsectors = (u16)rq->nr_sectors; | 143 | u16 nsectors = (u16)rq->nr_sectors; |
145 | u8 lba48 = (drive->addressing == 1) ? 1 : 0; | 144 | u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); |
145 | u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | ||
146 | ide_task_t task; | 146 | ide_task_t task; |
147 | struct ide_taskfile *tf = &task.tf; | 147 | struct ide_taskfile *tf = &task.tf; |
148 | ide_startstop_t rc; | 148 | ide_startstop_t rc; |
@@ -237,7 +237,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
237 | { | 237 | { |
238 | ide_hwif_t *hwif = HWIF(drive); | 238 | ide_hwif_t *hwif = HWIF(drive); |
239 | 239 | ||
240 | BUG_ON(drive->blocked); | 240 | BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); |
241 | 241 | ||
242 | if (!blk_fs_request(rq)) { | 242 | if (!blk_fs_request(rq)) { |
243 | blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command"); | 243 | blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command"); |
@@ -452,7 +452,7 @@ static int proc_idedisk_read_cache | |||
452 | char *out = page; | 452 | char *out = page; |
453 | int len; | 453 | int len; |
454 | 454 | ||
455 | if (drive->id_read) | 455 | if (drive->dev_flags & IDE_DFLAG_ID_READ) |
456 | len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); | 456 | len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); |
457 | else | 457 | else |
458 | len = sprintf(out, "(none)\n"); | 458 | len = sprintf(out, "(none)\n"); |
@@ -568,15 +568,20 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
568 | return (drive->mult_count == arg) ? 0 : -EIO; | 568 | return (drive->mult_count == arg) ? 0 : -EIO; |
569 | } | 569 | } |
570 | 570 | ||
571 | ide_devset_get(nowerr, nowerr); | 571 | ide_devset_get_flag(nowerr, IDE_DFLAG_NOWERR); |
572 | 572 | ||
573 | static int set_nowerr(ide_drive_t *drive, int arg) | 573 | static int set_nowerr(ide_drive_t *drive, int arg) |
574 | { | 574 | { |
575 | if (arg < 0 || arg > 1) | 575 | if (arg < 0 || arg > 1) |
576 | return -EINVAL; | 576 | return -EINVAL; |
577 | 577 | ||
578 | drive->nowerr = arg; | 578 | if (arg) |
579 | drive->dev_flags |= IDE_DFLAG_NOWERR; | ||
580 | else | ||
581 | drive->dev_flags &= ~IDE_DFLAG_NOWERR; | ||
582 | |||
579 | drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; | 583 | drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; |
584 | |||
580 | return 0; | 585 | return 0; |
581 | } | 586 | } |
582 | 587 | ||
@@ -599,7 +604,7 @@ static void update_ordered(ide_drive_t *drive) | |||
599 | unsigned ordered = QUEUE_ORDERED_NONE; | 604 | unsigned ordered = QUEUE_ORDERED_NONE; |
600 | prepare_flush_fn *prep_fn = NULL; | 605 | prepare_flush_fn *prep_fn = NULL; |
601 | 606 | ||
602 | if (drive->wcache) { | 607 | if (drive->dev_flags & IDE_DFLAG_WCACHE) { |
603 | unsigned long long capacity; | 608 | unsigned long long capacity; |
604 | int barrier; | 609 | int barrier; |
605 | /* | 610 | /* |
@@ -611,8 +616,10 @@ static void update_ordered(ide_drive_t *drive) | |||
611 | * not available so we don't need to recheck that. | 616 | * not available so we don't need to recheck that. |
612 | */ | 617 | */ |
613 | capacity = idedisk_capacity(drive); | 618 | capacity = idedisk_capacity(drive); |
614 | barrier = ata_id_flush_enabled(id) && !drive->noflush && | 619 | barrier = ata_id_flush_enabled(id) && |
615 | (drive->addressing == 0 || capacity <= (1ULL << 28) || | 620 | (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && |
621 | ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || | ||
622 | capacity <= (1ULL << 28) || | ||
616 | ata_id_flush_ext_enabled(id)); | 623 | ata_id_flush_ext_enabled(id)); |
617 | 624 | ||
618 | printk(KERN_INFO "%s: cache flushes %ssupported\n", | 625 | printk(KERN_INFO "%s: cache flushes %ssupported\n", |
@@ -628,7 +635,7 @@ static void update_ordered(ide_drive_t *drive) | |||
628 | blk_queue_ordered(drive->queue, ordered, prep_fn); | 635 | blk_queue_ordered(drive->queue, ordered, prep_fn); |
629 | } | 636 | } |
630 | 637 | ||
631 | ide_devset_get(wcache, wcache); | 638 | ide_devset_get_flag(wcache, IDE_DFLAG_WCACHE); |
632 | 639 | ||
633 | static int set_wcache(ide_drive_t *drive, int arg) | 640 | static int set_wcache(ide_drive_t *drive, int arg) |
634 | { | 641 | { |
@@ -640,8 +647,12 @@ static int set_wcache(ide_drive_t *drive, int arg) | |||
640 | if (ata_id_flush_enabled(drive->id)) { | 647 | if (ata_id_flush_enabled(drive->id)) { |
641 | err = ide_do_setfeature(drive, | 648 | err = ide_do_setfeature(drive, |
642 | arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0); | 649 | arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0); |
643 | if (err == 0) | 650 | if (err == 0) { |
644 | drive->wcache = arg; | 651 | if (arg) |
652 | drive->dev_flags |= IDE_DFLAG_WCACHE; | ||
653 | else | ||
654 | drive->dev_flags &= ~IDE_DFLAG_WCACHE; | ||
655 | } | ||
645 | } | 656 | } |
646 | 657 | ||
647 | update_ordered(drive); | 658 | update_ordered(drive); |
@@ -677,7 +688,7 @@ static int set_acoustic(ide_drive_t *drive, int arg) | |||
677 | return 0; | 688 | return 0; |
678 | } | 689 | } |
679 | 690 | ||
680 | ide_devset_get(addressing, addressing); | 691 | ide_devset_get_flag(addressing, IDE_DFLAG_LBA48); |
681 | 692 | ||
682 | /* | 693 | /* |
683 | * drive->addressing: | 694 | * drive->addressing: |
@@ -697,7 +708,10 @@ static int set_addressing(ide_drive_t *drive, int arg) | |||
697 | if (arg == 2) | 708 | if (arg == 2) |
698 | arg = 0; | 709 | arg = 0; |
699 | 710 | ||
700 | drive->addressing = arg; | 711 | if (arg) |
712 | drive->dev_flags |= IDE_DFLAG_LBA48; | ||
713 | else | ||
714 | drive->dev_flags &= ~IDE_DFLAG_LBA48; | ||
701 | 715 | ||
702 | return 0; | 716 | return 0; |
703 | } | 717 | } |
@@ -743,20 +757,20 @@ static void idedisk_setup(ide_drive_t *drive) | |||
743 | 757 | ||
744 | ide_proc_register_driver(drive, idkp->driver); | 758 | ide_proc_register_driver(drive, idkp->driver); |
745 | 759 | ||
746 | if (drive->id_read == 0) | 760 | if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) |
747 | return; | 761 | return; |
748 | 762 | ||
749 | if (drive->removable) { | 763 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) { |
750 | /* | 764 | /* |
751 | * Removable disks (eg. SYQUEST); ignore 'WD' drives | 765 | * Removable disks (eg. SYQUEST); ignore 'WD' drives |
752 | */ | 766 | */ |
753 | if (m[0] != 'W' || m[1] != 'D') | 767 | if (m[0] != 'W' || m[1] != 'D') |
754 | drive->doorlocking = 1; | 768 | drive->dev_flags |= IDE_DFLAG_DOORLOCKING; |
755 | } | 769 | } |
756 | 770 | ||
757 | (void)set_addressing(drive, 1); | 771 | (void)set_addressing(drive, 1); |
758 | 772 | ||
759 | if (drive->addressing == 1) { | 773 | if (drive->dev_flags & IDE_DFLAG_LBA48) { |
760 | int max_s = 2048; | 774 | int max_s = 2048; |
761 | 775 | ||
762 | if (max_s > hwif->rqsize) | 776 | if (max_s > hwif->rqsize) |
@@ -772,7 +786,8 @@ static void idedisk_setup(ide_drive_t *drive) | |||
772 | init_idedisk_capacity(drive); | 786 | init_idedisk_capacity(drive); |
773 | 787 | ||
774 | /* limit drive capacity to 137GB if LBA48 cannot be used */ | 788 | /* limit drive capacity to 137GB if LBA48 cannot be used */ |
775 | if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) { | 789 | if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 && |
790 | drive->capacity64 > 1ULL << 28) { | ||
776 | printk(KERN_WARNING "%s: cannot use LBA48 - full capacity " | 791 | printk(KERN_WARNING "%s: cannot use LBA48 - full capacity " |
777 | "%llu sectors (%llu MB)\n", | 792 | "%llu sectors (%llu MB)\n", |
778 | drive->name, (unsigned long long)drive->capacity64, | 793 | drive->name, (unsigned long long)drive->capacity64, |
@@ -780,13 +795,14 @@ static void idedisk_setup(ide_drive_t *drive) | |||
780 | drive->capacity64 = 1ULL << 28; | 795 | drive->capacity64 = 1ULL << 28; |
781 | } | 796 | } |
782 | 797 | ||
783 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) { | 798 | if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && |
799 | (drive->dev_flags & IDE_DFLAG_LBA48)) { | ||
784 | if (drive->capacity64 > 1ULL << 28) { | 800 | if (drive->capacity64 > 1ULL << 28) { |
785 | printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" | 801 | printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" |
786 | " will be used for accessing sectors " | 802 | " will be used for accessing sectors " |
787 | "> %u\n", drive->name, 1 << 28); | 803 | "> %u\n", drive->name, 1 << 28); |
788 | } else | 804 | } else |
789 | drive->addressing = 0; | 805 | drive->dev_flags &= ~IDE_DFLAG_LBA48; |
790 | } | 806 | } |
791 | 807 | ||
792 | /* | 808 | /* |
@@ -795,7 +811,7 @@ static void idedisk_setup(ide_drive_t *drive) | |||
795 | */ | 811 | */ |
796 | capacity = idedisk_capacity(drive); | 812 | capacity = idedisk_capacity(drive); |
797 | 813 | ||
798 | if (!drive->forced_geom) { | 814 | if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { |
799 | if (ata_id_lba48_enabled(drive->id)) { | 815 | if (ata_id_lba48_enabled(drive->id)) { |
800 | /* compatibility */ | 816 | /* compatibility */ |
801 | drive->bios_sect = 63; | 817 | drive->bios_sect = 63; |
@@ -830,14 +846,15 @@ static void idedisk_setup(ide_drive_t *drive) | |||
830 | 846 | ||
831 | /* write cache enabled? */ | 847 | /* write cache enabled? */ |
832 | if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id)) | 848 | if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id)) |
833 | drive->wcache = 1; | 849 | drive->dev_flags |= IDE_DFLAG_WCACHE; |
834 | 850 | ||
835 | set_wcache(drive, 1); | 851 | set_wcache(drive, 1); |
836 | } | 852 | } |
837 | 853 | ||
838 | static void ide_cacheflush_p(ide_drive_t *drive) | 854 | static void ide_cacheflush_p(ide_drive_t *drive) |
839 | { | 855 | { |
840 | if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) | 856 | if (ata_id_flush_enabled(drive->id) == 0 || |
857 | (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) | ||
841 | return; | 858 | return; |
842 | 859 | ||
843 | if (do_idedisk_flushcache(drive)) | 860 | if (do_idedisk_flushcache(drive)) |
@@ -956,15 +973,16 @@ static int idedisk_open(struct inode *inode, struct file *filp) | |||
956 | 973 | ||
957 | idkp->openers++; | 974 | idkp->openers++; |
958 | 975 | ||
959 | if (drive->removable && idkp->openers == 1) { | 976 | if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) { |
960 | check_disk_change(inode->i_bdev); | 977 | check_disk_change(inode->i_bdev); |
961 | /* | 978 | /* |
962 | * Ignore the return code from door_lock, | 979 | * Ignore the return code from door_lock, |
963 | * since the open() has already succeeded, | 980 | * since the open() has already succeeded, |
964 | * and the door_lock is irrelevant at this point. | 981 | * and the door_lock is irrelevant at this point. |
965 | */ | 982 | */ |
966 | if (drive->doorlocking && idedisk_set_doorlock(drive, 1)) | 983 | if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && |
967 | drive->doorlocking = 0; | 984 | idedisk_set_doorlock(drive, 1)) |
985 | drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; | ||
968 | } | 986 | } |
969 | return 0; | 987 | return 0; |
970 | } | 988 | } |
@@ -978,9 +996,10 @@ static int idedisk_release(struct inode *inode, struct file *filp) | |||
978 | if (idkp->openers == 1) | 996 | if (idkp->openers == 1) |
979 | ide_cacheflush_p(drive); | 997 | ide_cacheflush_p(drive); |
980 | 998 | ||
981 | if (drive->removable && idkp->openers == 1) { | 999 | if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) { |
982 | if (drive->doorlocking && idedisk_set_doorlock(drive, 0)) | 1000 | if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && |
983 | drive->doorlocking = 0; | 1001 | idedisk_set_doorlock(drive, 0)) |
1002 | drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; | ||
984 | } | 1003 | } |
985 | 1004 | ||
986 | idkp->openers--; | 1005 | idkp->openers--; |
@@ -1031,12 +1050,13 @@ static int idedisk_media_changed(struct gendisk *disk) | |||
1031 | ide_drive_t *drive = idkp->drive; | 1050 | ide_drive_t *drive = idkp->drive; |
1032 | 1051 | ||
1033 | /* do not scan partitions twice if this is a removable device */ | 1052 | /* do not scan partitions twice if this is a removable device */ |
1034 | if (drive->attach) { | 1053 | if (drive->dev_flags & IDE_DFLAG_ATTACH) { |
1035 | drive->attach = 0; | 1054 | drive->dev_flags &= ~IDE_DFLAG_ATTACH; |
1036 | return 0; | 1055 | return 0; |
1037 | } | 1056 | } |
1057 | |||
1038 | /* if removable, always assume it was changed */ | 1058 | /* if removable, always assume it was changed */ |
1039 | return drive->removable; | 1059 | return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE); |
1040 | } | 1060 | } |
1041 | 1061 | ||
1042 | static int idedisk_revalidate_disk(struct gendisk *disk) | 1062 | static int idedisk_revalidate_disk(struct gendisk *disk) |
@@ -1094,15 +1114,15 @@ static int ide_disk_probe(ide_drive_t *drive) | |||
1094 | if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { | 1114 | if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { |
1095 | printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", | 1115 | printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", |
1096 | drive->name, drive->head); | 1116 | drive->name, drive->head); |
1097 | drive->attach = 0; | 1117 | drive->dev_flags &= ~IDE_DFLAG_ATTACH; |
1098 | } else | 1118 | } else |
1099 | drive->attach = 1; | 1119 | drive->dev_flags |= IDE_DFLAG_ATTACH; |
1100 | 1120 | ||
1101 | g->minors = IDE_DISK_MINORS; | 1121 | g->minors = IDE_DISK_MINORS; |
1102 | g->driverfs_dev = &drive->gendev; | 1122 | g->driverfs_dev = &drive->gendev; |
1103 | g->flags |= GENHD_FL_EXT_DEVT; | 1123 | g->flags |= GENHD_FL_EXT_DEVT; |
1104 | if (drive->removable) | 1124 | if (drive->dev_flags & IDE_DFLAG_REMOVABLE) |
1105 | g->flags |= GENHD_FL_REMOVABLE; | 1125 | g->flags = GENHD_FL_REMOVABLE; |
1106 | set_capacity(g, idedisk_capacity(drive)); | 1126 | set_capacity(g, idedisk_capacity(drive)); |
1107 | g->fops = &idedisk_ops; | 1127 | g->fops = &idedisk_ops; |
1108 | add_disk(g); | 1128 | add_disk(g); |