aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:19 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:19 -0400
commit48fb2688aa67baba373531cc4ed2d9e695983c3f (patch)
tree9382e5175e43b914fd06bb778cc6f37a4967ab9d /drivers/ide/ide-disk.c
parent4dde4492d850a4c9bcaa92e5bd7f4eebe3e2f5ab (diff)
ide: remove drive->driveid
* Factor out HDIO_[OBSOLETE,GET]_IDENTITY ioctls handling to ide_get_identity_ioctl(). * Use temporary buffer in ide_get_identity_ioctl() instead of accessing drive->id directly. * Add ide_id_to_hd_driveid() inline to convert raw id into struct hd_driveid format (needed on big-endian). * Use ide_id_to_hd_driveid() in ide_get_identity_ioctl(), cleanup ide_fix_driveid() and switch ide to use use raw id. * Remove no longer needed drive->driveid. This leaves us with 3 users of struct hd_driveid in tree: - arch/um/drivers/ubd_kern.c - drivers/block/xsysace.c - drivers/usb/storage/isd200.c While at it: * Use ata_id_u{32,64}() and ata_id_has_{dma,lba,iordy}() macros. 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.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index f1669bca3cab..8f1ec037309a 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -101,13 +101,14 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
101 */ 101 */
102static int lba_capacity_is_ok(u16 *id) 102static int lba_capacity_is_ok(u16 *id)
103{ 103{
104 struct hd_driveid *driveid = (struct hd_driveid *)id;
105 unsigned long lba_sects, chs_sects, head, tail; 104 unsigned long lba_sects, chs_sects, head, tail;
106 105
107 /* No non-LBA info .. so valid! */ 106 /* No non-LBA info .. so valid! */
108 if (id[ATA_ID_CYLS] == 0) 107 if (id[ATA_ID_CYLS] == 0)
109 return 1; 108 return 1;
110 109
110 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
111
111 /* 112 /*
112 * The ATA spec tells large drives to return 113 * The ATA spec tells large drives to return
113 * C/H/S = 16383/16/63 independent of their size. 114 * C/H/S = 16383/16/63 independent of their size.
@@ -118,10 +119,9 @@ static int lba_capacity_is_ok(u16 *id)
118 (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && 119 (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) &&
119 id[ATA_ID_SECTORS] == 63 && 120 id[ATA_ID_SECTORS] == 63 &&
120 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && 121 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
121 (driveid->lba_capacity >= 16383 * 63 * id[ATA_ID_HEADS])) 122 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
122 return 1; 123 return 1;
123 124
124 lba_sects = driveid->lba_capacity;
125 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; 125 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
126 126
127 /* perform a rough sanity check on lba_sects: within 10% is OK */ 127 /* perform a rough sanity check on lba_sects: within 10% is OK */
@@ -133,7 +133,7 @@ static int lba_capacity_is_ok(u16 *id)
133 tail = (lba_sects & 0xffff); 133 tail = (lba_sects & 0xffff);
134 lba_sects = (head | (tail << 16)); 134 lba_sects = (head | (tail << 16));
135 if ((lba_sects - chs_sects) < chs_sects/10) { 135 if ((lba_sects - chs_sects) < chs_sects/10) {
136 driveid->lba_capacity = lba_sects; 136 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
137 return 1; /* lba_capacity is (now) good */ 137 return 1; /* lba_capacity is (now) good */
138 } 138 }
139 139
@@ -403,7 +403,7 @@ static inline int idedisk_supports_lba48(const u16 *id)
403{ 403{
404 return (id[ATA_ID_COMMAND_SET_2] & 0x0400) && 404 return (id[ATA_ID_COMMAND_SET_2] & 0x0400) &&
405 (id[ATA_ID_CFS_ENABLE_2] & 0x0400) && 405 (id[ATA_ID_CFS_ENABLE_2] & 0x0400) &&
406 ((struct hd_driveid *)id)->lba_capacity_2; 406 ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
407} 407}
408 408
409/* 409/*
@@ -456,7 +456,6 @@ static void idedisk_check_hpa(ide_drive_t *drive)
456 456
457static void init_idedisk_capacity(ide_drive_t *drive) 457static void init_idedisk_capacity(ide_drive_t *drive)
458{ 458{
459 struct hd_driveid *driveid = drive->driveid;
460 u16 *id = drive->id; 459 u16 *id = drive->id;
461 /* 460 /*
462 * If this drive supports the Host Protected Area feature set, 461 * If this drive supports the Host Protected Area feature set,
@@ -467,13 +466,13 @@ static void init_idedisk_capacity(ide_drive_t *drive)
467 if (idedisk_supports_lba48(id)) { 466 if (idedisk_supports_lba48(id)) {
468 /* drive speaks 48-bit LBA */ 467 /* drive speaks 48-bit LBA */
469 drive->select.b.lba = 1; 468 drive->select.b.lba = 1;
470 drive->capacity64 = driveid->lba_capacity_2; 469 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
471 if (hpa) 470 if (hpa)
472 idedisk_check_hpa(drive); 471 idedisk_check_hpa(drive);
473 } else if ((driveid->capability & 2) && lba_capacity_is_ok(id)) { 472 } else if (ata_id_has_lba(id) && lba_capacity_is_ok(id)) {
474 /* drive speaks 28-bit LBA */ 473 /* drive speaks 28-bit LBA */
475 drive->select.b.lba = 1; 474 drive->select.b.lba = 1;
476 drive->capacity64 = driveid->lba_capacity; 475 drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
477 if (hpa) 476 if (hpa)
478 idedisk_check_hpa(drive); 477 idedisk_check_hpa(drive);
479 } else { 478 } else {
@@ -622,7 +621,7 @@ static int set_multcount(ide_drive_t *drive, int arg)
622 struct request *rq; 621 struct request *rq;
623 int error; 622 int error;
624 623
625 if (arg < 0 || arg > drive->driveid->max_multsect) 624 if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff))
626 return -EINVAL; 625 return -EINVAL;
627 626
628 if (drive->special.b.set_multmode) 627 if (drive->special.b.set_multmode)
@@ -775,8 +774,8 @@ static void idedisk_add_settings(ide_drive_t *drive)
775 ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, 774 ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1,
776 &drive->addressing, set_lba_addressing); 775 &drive->addressing, set_lba_addressing);
777 ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, 776 ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0,
778 drive->driveid->max_multsect, 1, 1, &drive->mult_count, 777 drive->id[ATA_ID_MAX_MULTSECT] & 0xff, 1, 1,
779 set_multcount); 778 &drive->mult_count, set_multcount);
780 ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, 779 ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1,
781 &drive->nowerr, set_nowerr); 780 &drive->nowerr, set_nowerr);
782 ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, 781 ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1,