diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:31 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:31 -0400 |
commit | a02227c9774b3bff08c7f557d06247e0a03ac435 (patch) | |
tree | 53bd926333ce6269043fae426144312e163e1fe9 | |
parent | 93734a234447a3c091f76d76f7351af9d4dde518 (diff) |
ide: lba_capacity_is_ok() -> ata_id_is_lba_capacity_ok()
Rename lba_capacity_is_ok() to ata_id_is_lba_capacity_ok()
and move it to <linux/ata.h> (remove needless parens while at it).
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-disk.c | 52 | ||||
-rw-r--r-- | include/linux/ata.h | 50 |
2 files changed, 51 insertions, 51 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 587d5aac7d5d..43025c9d8355 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -88,56 +88,6 @@ static void ide_disk_put(struct ide_disk_obj *idkp) | |||
88 | mutex_unlock(&idedisk_ref_mutex); | 88 | mutex_unlock(&idedisk_ref_mutex); |
89 | } | 89 | } |
90 | 90 | ||
91 | /* | ||
92 | * lba_capacity_is_ok() performs a sanity check on the claimed "lba_capacity" | ||
93 | * value for this drive (from its reported identification information). | ||
94 | * | ||
95 | * Returns: 1 if lba_capacity looks sensible | ||
96 | * 0 otherwise | ||
97 | * | ||
98 | * It is called only once for each drive. | ||
99 | */ | ||
100 | static int lba_capacity_is_ok(u16 *id) | ||
101 | { | ||
102 | unsigned long lba_sects, chs_sects, head, tail; | ||
103 | |||
104 | /* No non-LBA info .. so valid! */ | ||
105 | if (id[ATA_ID_CYLS] == 0) | ||
106 | return 1; | ||
107 | |||
108 | lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
109 | |||
110 | /* | ||
111 | * The ATA spec tells large drives to return | ||
112 | * C/H/S = 16383/16/63 independent of their size. | ||
113 | * Some drives can be jumpered to use 15 heads instead of 16. | ||
114 | * Some drives can be jumpered to use 4092 cyls instead of 16383. | ||
115 | */ | ||
116 | if ((id[ATA_ID_CYLS] == 16383 || | ||
117 | (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && | ||
118 | id[ATA_ID_SECTORS] == 63 && | ||
119 | (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && | ||
120 | (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) | ||
121 | return 1; | ||
122 | |||
123 | chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; | ||
124 | |||
125 | /* perform a rough sanity check on lba_sects: within 10% is OK */ | ||
126 | if ((lba_sects - chs_sects) < chs_sects/10) | ||
127 | return 1; | ||
128 | |||
129 | /* some drives have the word order reversed */ | ||
130 | head = ((lba_sects >> 16) & 0xffff); | ||
131 | tail = (lba_sects & 0xffff); | ||
132 | lba_sects = (head | (tail << 16)); | ||
133 | if ((lba_sects - chs_sects) < chs_sects/10) { | ||
134 | *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); | ||
135 | return 1; /* lba_capacity is (now) good */ | ||
136 | } | ||
137 | |||
138 | return 0; /* lba_capacity value may be bad */ | ||
139 | } | ||
140 | |||
141 | static const u8 ide_rw_cmds[] = { | 91 | static const u8 ide_rw_cmds[] = { |
142 | ATA_CMD_READ_MULTI, | 92 | ATA_CMD_READ_MULTI, |
143 | ATA_CMD_WRITE_MULTI, | 93 | ATA_CMD_WRITE_MULTI, |
@@ -446,7 +396,7 @@ static void init_idedisk_capacity(ide_drive_t *drive) | |||
446 | drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); | 396 | drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); |
447 | if (hpa) | 397 | if (hpa) |
448 | idedisk_check_hpa(drive); | 398 | idedisk_check_hpa(drive); |
449 | } else if (ata_id_has_lba(id) && lba_capacity_is_ok(id)) { | 399 | } else if (ata_id_has_lba(id) && ata_id_is_lba_capacity_ok(id)) { |
450 | /* drive speaks 28-bit LBA */ | 400 | /* drive speaks 28-bit LBA */ |
451 | drive->select.b.lba = 1; | 401 | drive->select.b.lba = 1; |
452 | drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | 402 | drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); |
diff --git a/include/linux/ata.h b/include/linux/ata.h index 4c3f50070033..a53318b8cbd0 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -782,6 +782,56 @@ static inline int atapi_id_dmadir(const u16 *dev_id) | |||
782 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); | 782 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); |
783 | } | 783 | } |
784 | 784 | ||
785 | /* | ||
786 | * ata_id_is_lba_capacity_ok() performs a sanity check on | ||
787 | * the claimed LBA capacity value for the device. | ||
788 | * | ||
789 | * Returns 1 if LBA capacity looks sensible, 0 otherwise. | ||
790 | * | ||
791 | * It is called only once for each device. | ||
792 | */ | ||
793 | static inline int ata_id_is_lba_capacity_ok(u16 *id) | ||
794 | { | ||
795 | unsigned long lba_sects, chs_sects, head, tail; | ||
796 | |||
797 | /* No non-LBA info .. so valid! */ | ||
798 | if (id[ATA_ID_CYLS] == 0) | ||
799 | return 1; | ||
800 | |||
801 | lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
802 | |||
803 | /* | ||
804 | * The ATA spec tells large drives to return | ||
805 | * C/H/S = 16383/16/63 independent of their size. | ||
806 | * Some drives can be jumpered to use 15 heads instead of 16. | ||
807 | * Some drives can be jumpered to use 4092 cyls instead of 16383. | ||
808 | */ | ||
809 | if ((id[ATA_ID_CYLS] == 16383 || | ||
810 | (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && | ||
811 | id[ATA_ID_SECTORS] == 63 && | ||
812 | (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && | ||
813 | (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) | ||
814 | return 1; | ||
815 | |||
816 | chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; | ||
817 | |||
818 | /* perform a rough sanity check on lba_sects: within 10% is OK */ | ||
819 | if (lba_sects - chs_sects < chs_sects/10) | ||
820 | return 1; | ||
821 | |||
822 | /* some drives have the word order reversed */ | ||
823 | head = (lba_sects >> 16) & 0xffff; | ||
824 | tail = lba_sects & 0xffff; | ||
825 | lba_sects = head | (tail << 16); | ||
826 | |||
827 | if (lba_sects - chs_sects < chs_sects/10) { | ||
828 | *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); | ||
829 | return 1; /* LBA capacity is (now) good */ | ||
830 | } | ||
831 | |||
832 | return 0; /* LBA capacity value may be bad */ | ||
833 | } | ||
834 | |||
785 | static inline void ata_id_to_hd_driveid(u16 *id) | 835 | static inline void ata_id_to_hd_driveid(u16 *id) |
786 | { | 836 | { |
787 | #ifdef __BIG_ENDIAN | 837 | #ifdef __BIG_ENDIAN |