diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:19 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:19 -0400 |
commit | 4dde4492d850a4c9bcaa92e5bd7f4eebe3e2f5ab (patch) | |
tree | ee3be70390e4c617b44329edef0a05039f59c81a /drivers/ide/ide-disk.c | |
parent | 5b90e990928919ae411a68b865e8a6ecac09a603 (diff) |
ide: make drive->id an union (take 2)
Make drive->id an unnamed union so id can be accessed either by using
'u16 *id' or 'struct hd_driveid *driveid'. Then convert all existing
drive->id users accordingly (using 'u16 *id' when possible).
This is an intermediate step to make ide 'struct hd_driveid'-free.
While at it:
- Add missing KERN_CONTs in it821x.c.
- Use ATA_ID_WORDS and ATA_ID_*_LEN defines.
- Remove unnecessary checks for drive->id.
- s/drive_table/table/ in ide_in_drive_list().
- Cleanup ide_config_drive_speed() a bit.
- s/drive1/dev1/ & s/drive0/dev0/ in ide_undecoded_slave().
v2:
Fix typo in drivers/ide/ppc/pmac.c. (From Stephen Rothwell)
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 | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 33ea8c048717..f1669bca3cab 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -99,12 +99,13 @@ static void ide_disk_put(struct ide_disk_obj *idkp) | |||
99 | * | 99 | * |
100 | * It is called only once for each drive. | 100 | * It is called only once for each drive. |
101 | */ | 101 | */ |
102 | static int lba_capacity_is_ok(struct hd_driveid *id) | 102 | static int lba_capacity_is_ok(u16 *id) |
103 | { | 103 | { |
104 | struct hd_driveid *driveid = (struct hd_driveid *)id; | ||
104 | unsigned long lba_sects, chs_sects, head, tail; | 105 | unsigned long lba_sects, chs_sects, head, tail; |
105 | 106 | ||
106 | /* No non-LBA info .. so valid! */ | 107 | /* No non-LBA info .. so valid! */ |
107 | if (id->cyls == 0) | 108 | if (id[ATA_ID_CYLS] == 0) |
108 | return 1; | 109 | return 1; |
109 | 110 | ||
110 | /* | 111 | /* |
@@ -113,15 +114,15 @@ static int lba_capacity_is_ok(struct hd_driveid *id) | |||
113 | * Some drives can be jumpered to use 15 heads instead of 16. | 114 | * 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 | * Some drives can be jumpered to use 4092 cyls instead of 16383. |
115 | */ | 116 | */ |
116 | if ((id->cyls == 16383 | 117 | if ((id[ATA_ID_CYLS] == 16383 || |
117 | || (id->cyls == 4092 && id->cur_cyls == 16383)) && | 118 | (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && |
118 | id->sectors == 63 && | 119 | id[ATA_ID_SECTORS] == 63 && |
119 | (id->heads == 15 || id->heads == 16) && | 120 | (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && |
120 | (id->lba_capacity >= 16383*63*id->heads)) | 121 | (driveid->lba_capacity >= 16383 * 63 * id[ATA_ID_HEADS])) |
121 | return 1; | 122 | return 1; |
122 | 123 | ||
123 | lba_sects = id->lba_capacity; | 124 | lba_sects = driveid->lba_capacity; |
124 | chs_sects = id->cyls * id->heads * id->sectors; | 125 | chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; |
125 | 126 | ||
126 | /* 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 */ |
127 | if ((lba_sects - chs_sects) < chs_sects/10) | 128 | if ((lba_sects - chs_sects) < chs_sects/10) |
@@ -132,7 +133,7 @@ static int lba_capacity_is_ok(struct hd_driveid *id) | |||
132 | tail = (lba_sects & 0xffff); | 133 | tail = (lba_sects & 0xffff); |
133 | lba_sects = (head | (tail << 16)); | 134 | lba_sects = (head | (tail << 16)); |
134 | if ((lba_sects - chs_sects) < chs_sects/10) { | 135 | if ((lba_sects - chs_sects) < chs_sects/10) { |
135 | id->lba_capacity = lba_sects; | 136 | driveid->lba_capacity = lba_sects; |
136 | return 1; /* lba_capacity is (now) good */ | 137 | return 1; /* lba_capacity is (now) good */ |
137 | } | 138 | } |
138 | 139 | ||
@@ -389,18 +390,20 @@ static unsigned long long sectors_to_MB(unsigned long long n) | |||
389 | * so on non-buggy drives we need test only one. | 390 | * so on non-buggy drives we need test only one. |
390 | * However, we should also check whether these fields are valid. | 391 | * However, we should also check whether these fields are valid. |
391 | */ | 392 | */ |
392 | static inline int idedisk_supports_hpa(const struct hd_driveid *id) | 393 | static inline int idedisk_supports_hpa(const u16 *id) |
393 | { | 394 | { |
394 | return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400); | 395 | return (id[ATA_ID_COMMAND_SET_1] & 0x0400) && |
396 | (id[ATA_ID_CFS_ENABLE_1] & 0x0400); | ||
395 | } | 397 | } |
396 | 398 | ||
397 | /* | 399 | /* |
398 | * The same here. | 400 | * The same here. |
399 | */ | 401 | */ |
400 | static inline int idedisk_supports_lba48(const struct hd_driveid *id) | 402 | static inline int idedisk_supports_lba48(const u16 *id) |
401 | { | 403 | { |
402 | return (id->command_set_2 & 0x0400) && (id->cfs_enable_2 & 0x0400) | 404 | return (id[ATA_ID_COMMAND_SET_2] & 0x0400) && |
403 | && id->lba_capacity_2; | 405 | (id[ATA_ID_CFS_ENABLE_2] & 0x0400) && |
406 | ((struct hd_driveid *)id)->lba_capacity_2; | ||
404 | } | 407 | } |
405 | 408 | ||
406 | /* | 409 | /* |
@@ -453,7 +456,8 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
453 | 456 | ||
454 | static void init_idedisk_capacity(ide_drive_t *drive) | 457 | static void init_idedisk_capacity(ide_drive_t *drive) |
455 | { | 458 | { |
456 | struct hd_driveid *id = drive->id; | 459 | struct hd_driveid *driveid = drive->driveid; |
460 | u16 *id = drive->id; | ||
457 | /* | 461 | /* |
458 | * If this drive supports the Host Protected Area feature set, | 462 | * If this drive supports the Host Protected Area feature set, |
459 | * then we may need to change our opinion about the drive's capacity. | 463 | * then we may need to change our opinion about the drive's capacity. |
@@ -463,13 +467,13 @@ static void init_idedisk_capacity(ide_drive_t *drive) | |||
463 | if (idedisk_supports_lba48(id)) { | 467 | if (idedisk_supports_lba48(id)) { |
464 | /* drive speaks 48-bit LBA */ | 468 | /* drive speaks 48-bit LBA */ |
465 | drive->select.b.lba = 1; | 469 | drive->select.b.lba = 1; |
466 | drive->capacity64 = id->lba_capacity_2; | 470 | drive->capacity64 = driveid->lba_capacity_2; |
467 | if (hpa) | 471 | if (hpa) |
468 | idedisk_check_hpa(drive); | 472 | idedisk_check_hpa(drive); |
469 | } else if ((id->capability & 2) && lba_capacity_is_ok(id)) { | 473 | } else if ((driveid->capability & 2) && lba_capacity_is_ok(id)) { |
470 | /* drive speaks 28-bit LBA */ | 474 | /* drive speaks 28-bit LBA */ |
471 | drive->select.b.lba = 1; | 475 | drive->select.b.lba = 1; |
472 | drive->capacity64 = id->lba_capacity; | 476 | drive->capacity64 = driveid->lba_capacity; |
473 | if (hpa) | 477 | if (hpa) |
474 | idedisk_check_hpa(drive); | 478 | idedisk_check_hpa(drive); |
475 | } else { | 479 | } else { |
@@ -523,7 +527,7 @@ static int proc_idedisk_read_cache | |||
523 | int len; | 527 | int len; |
524 | 528 | ||
525 | if (drive->id_read) | 529 | if (drive->id_read) |
526 | len = sprintf(out, "%i\n", drive->id->buf_size / 2); | 530 | len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); |
527 | else | 531 | else |
528 | len = sprintf(out, "(none)\n"); | 532 | len = sprintf(out, "(none)\n"); |
529 | 533 | ||
@@ -618,7 +622,7 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
618 | struct request *rq; | 622 | struct request *rq; |
619 | int error; | 623 | int error; |
620 | 624 | ||
621 | if (arg < 0 || arg > drive->id->max_multsect) | 625 | if (arg < 0 || arg > drive->driveid->max_multsect) |
622 | return -EINVAL; | 626 | return -EINVAL; |
623 | 627 | ||
624 | if (drive->special.b.set_multmode) | 628 | if (drive->special.b.set_multmode) |
@@ -650,7 +654,7 @@ static int set_nowerr(ide_drive_t *drive, int arg) | |||
650 | 654 | ||
651 | static void update_ordered(ide_drive_t *drive) | 655 | static void update_ordered(ide_drive_t *drive) |
652 | { | 656 | { |
653 | struct hd_driveid *id = drive->id; | 657 | u16 *id = drive->id; |
654 | unsigned ordered = QUEUE_ORDERED_NONE; | 658 | unsigned ordered = QUEUE_ORDERED_NONE; |
655 | prepare_flush_fn *prep_fn = NULL; | 659 | prepare_flush_fn *prep_fn = NULL; |
656 | 660 | ||
@@ -762,8 +766,6 @@ static int set_lba_addressing(ide_drive_t *drive, int arg) | |||
762 | #ifdef CONFIG_IDE_PROC_FS | 766 | #ifdef CONFIG_IDE_PROC_FS |
763 | static void idedisk_add_settings(ide_drive_t *drive) | 767 | static void idedisk_add_settings(ide_drive_t *drive) |
764 | { | 768 | { |
765 | struct hd_driveid *id = drive->id; | ||
766 | |||
767 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, | 769 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, |
768 | &drive->bios_cyl, NULL); | 770 | &drive->bios_cyl, NULL); |
769 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, | 771 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
@@ -773,7 +775,7 @@ static void idedisk_add_settings(ide_drive_t *drive) | |||
773 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, | 775 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, |
774 | &drive->addressing, set_lba_addressing); | 776 | &drive->addressing, set_lba_addressing); |
775 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, | 777 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, |
776 | id->max_multsect, 1, 1, &drive->mult_count, | 778 | drive->driveid->max_multsect, 1, 1, &drive->mult_count, |
777 | set_multcount); | 779 | set_multcount); |
778 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | 780 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, |
779 | &drive->nowerr, set_nowerr); | 781 | &drive->nowerr, set_nowerr); |
@@ -795,7 +797,8 @@ static inline void idedisk_add_settings(ide_drive_t *drive) { ; } | |||
795 | static void idedisk_setup(ide_drive_t *drive) | 797 | static void idedisk_setup(ide_drive_t *drive) |
796 | { | 798 | { |
797 | ide_hwif_t *hwif = drive->hwif; | 799 | ide_hwif_t *hwif = drive->hwif; |
798 | struct hd_driveid *id = drive->id; | 800 | u16 *id = drive->id; |
801 | char *m = (char *)&id[ATA_ID_PROD]; | ||
799 | unsigned long long capacity; | 802 | unsigned long long capacity; |
800 | 803 | ||
801 | idedisk_add_settings(drive); | 804 | idedisk_add_settings(drive); |
@@ -807,7 +810,7 @@ static void idedisk_setup(ide_drive_t *drive) | |||
807 | /* | 810 | /* |
808 | * Removable disks (eg. SYQUEST); ignore 'WD' drives | 811 | * Removable disks (eg. SYQUEST); ignore 'WD' drives |
809 | */ | 812 | */ |
810 | if (id->model[0] != 'W' || id->model[1] != 'D') | 813 | if (m[0] != 'W' || m[1] != 'D') |
811 | drive->doorlocking = 1; | 814 | drive->doorlocking = 1; |
812 | } | 815 | } |
813 | 816 | ||
@@ -880,14 +883,14 @@ static void idedisk_setup(ide_drive_t *drive) | |||
880 | drive->name, capacity, sectors_to_MB(capacity)); | 883 | drive->name, capacity, sectors_to_MB(capacity)); |
881 | 884 | ||
882 | /* Only print cache size when it was specified */ | 885 | /* Only print cache size when it was specified */ |
883 | if (id->buf_size) | 886 | if (id[ATA_ID_BUF_SIZE]) |
884 | printk(KERN_CONT " w/%dKiB Cache", id->buf_size / 2); | 887 | printk(KERN_CONT " w/%dKiB Cache", id[ATA_ID_BUF_SIZE] / 2); |
885 | 888 | ||
886 | printk(KERN_CONT ", CHS=%d/%d/%d\n", | 889 | printk(KERN_CONT ", CHS=%d/%d/%d\n", |
887 | drive->bios_cyl, drive->bios_head, drive->bios_sect); | 890 | drive->bios_cyl, drive->bios_head, drive->bios_sect); |
888 | 891 | ||
889 | /* write cache enabled? */ | 892 | /* write cache enabled? */ |
890 | if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5))) | 893 | if ((id[ATA_ID_CSFO] & 1) || (id[ATA_ID_CFS_ENABLE_1] & (1 << 5))) |
891 | drive->wcache = 1; | 894 | drive->wcache = 1; |
892 | 895 | ||
893 | write_cache(drive, 1); | 896 | write_cache(drive, 1); |