aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:31 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:31 -0400
commita02227c9774b3bff08c7f557d06247e0a03ac435 (patch)
tree53bd926333ce6269043fae426144312e163e1fe9 /drivers/ide/ide-disk.c
parent93734a234447a3c091f76d76f7351af9d4dde518 (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>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c52
1 files changed, 1 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 */
100static 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
141static const u8 ide_rw_cmds[] = { 91static 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);