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-iops.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-iops.c')
-rw-r--r-- | drivers/ide/ide-iops.c | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 68d655e0fa47..01b1943b315e 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -400,11 +400,11 @@ const struct ide_tp_ops default_tp_ops = { | |||
400 | .output_data = ide_output_data, | 400 | .output_data = ide_output_data, |
401 | }; | 401 | }; |
402 | 402 | ||
403 | void ide_fix_driveid(struct hd_driveid *driveid) | 403 | void ide_fix_driveid(u16 *id) |
404 | { | 404 | { |
405 | #ifndef __LITTLE_ENDIAN | 405 | #ifndef __LITTLE_ENDIAN |
406 | # ifdef __BIG_ENDIAN | 406 | # ifdef __BIG_ENDIAN |
407 | u16 *id = (u16 *)driveid; | 407 | struct hd_driveid *driveid = (struct hd_driveid *)id; |
408 | int i; | 408 | int i; |
409 | 409 | ||
410 | for (i = 0; i < 256; i++) { | 410 | for (i = 0; i < 256; i++) { |
@@ -593,18 +593,18 @@ EXPORT_SYMBOL(ide_wait_stat); | |||
593 | /** | 593 | /** |
594 | * ide_in_drive_list - look for drive in black/white list | 594 | * ide_in_drive_list - look for drive in black/white list |
595 | * @id: drive identifier | 595 | * @id: drive identifier |
596 | * @drive_table: list to inspect | 596 | * @table: list to inspect |
597 | * | 597 | * |
598 | * Look for a drive in the blacklist and the whitelist tables | 598 | * Look for a drive in the blacklist and the whitelist tables |
599 | * Returns 1 if the drive is found in the table. | 599 | * Returns 1 if the drive is found in the table. |
600 | */ | 600 | */ |
601 | 601 | ||
602 | int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table) | 602 | int ide_in_drive_list(u16 *id, const struct drive_list_entry *table) |
603 | { | 603 | { |
604 | for ( ; drive_table->id_model; drive_table++) | 604 | for ( ; table->id_model; table++) |
605 | if ((!strcmp(drive_table->id_model, id->model)) && | 605 | if ((!strcmp(table->id_model, (char *)&id[ATA_ID_PROD])) && |
606 | (!drive_table->id_firmware || | 606 | (!table->id_firmware || |
607 | strstr(id->fw_rev, drive_table->id_firmware))) | 607 | strstr((char *)&id[ATA_ID_FW_REV], table->id_firmware))) |
608 | return 1; | 608 | return 1; |
609 | return 0; | 609 | return 0; |
610 | } | 610 | } |
@@ -635,7 +635,7 @@ static const struct drive_list_entry ivb_list[] = { | |||
635 | u8 eighty_ninty_three (ide_drive_t *drive) | 635 | u8 eighty_ninty_three (ide_drive_t *drive) |
636 | { | 636 | { |
637 | ide_hwif_t *hwif = drive->hwif; | 637 | ide_hwif_t *hwif = drive->hwif; |
638 | struct hd_driveid *id = drive->id; | 638 | u16 *id = drive->id; |
639 | int ivb = ide_in_drive_list(id, ivb_list); | 639 | int ivb = ide_in_drive_list(id, ivb_list); |
640 | 640 | ||
641 | if (hwif->cbl == ATA_CBL_PATA40_SHORT) | 641 | if (hwif->cbl == ATA_CBL_PATA40_SHORT) |
@@ -657,7 +657,8 @@ u8 eighty_ninty_three (ide_drive_t *drive) | |||
657 | * - force bit13 (80c cable present) check also for !ivb devices | 657 | * - force bit13 (80c cable present) check also for !ivb devices |
658 | * (unless the slave device is pre-ATA3) | 658 | * (unless the slave device is pre-ATA3) |
659 | */ | 659 | */ |
660 | if ((id->hw_config & 0x4000) || (ivb && (id->hw_config & 0x2000))) | 660 | if ((id[ATA_ID_HW_CONFIG] & 0x4000) || |
661 | (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000))) | ||
661 | return 1; | 662 | return 1; |
662 | 663 | ||
663 | no_80w: | 664 | no_80w: |
@@ -678,7 +679,7 @@ int ide_driveid_update(ide_drive_t *drive) | |||
678 | { | 679 | { |
679 | ide_hwif_t *hwif = drive->hwif; | 680 | ide_hwif_t *hwif = drive->hwif; |
680 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 681 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
681 | struct hd_driveid *id; | 682 | u16 *id; |
682 | unsigned long timeout, flags; | 683 | unsigned long timeout, flags; |
683 | u8 stat; | 684 | u8 stat; |
684 | 685 | ||
@@ -722,16 +723,16 @@ int ide_driveid_update(ide_drive_t *drive) | |||
722 | local_irq_enable(); | 723 | local_irq_enable(); |
723 | local_irq_restore(flags); | 724 | local_irq_restore(flags); |
724 | ide_fix_driveid(id); | 725 | ide_fix_driveid(id); |
725 | if (id) { | 726 | |
726 | drive->id->dma_ultra = id->dma_ultra; | 727 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; |
727 | drive->id->dma_mword = id->dma_mword; | 728 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; |
728 | drive->id->dma_1word = id->dma_1word; | 729 | drive->id[ATA_ID_SWDMA_MODES] = id[ATA_ID_SWDMA_MODES]; |
729 | /* anything more ? */ | 730 | /* anything more ? */ |
730 | kfree(id); | 731 | |
731 | 732 | kfree(id); | |
732 | if (drive->using_dma && ide_id_dma_bug(drive)) | 733 | |
733 | ide_dma_off(drive); | 734 | if (drive->using_dma && ide_id_dma_bug(drive)) |
734 | } | 735 | ide_dma_off(drive); |
735 | 736 | ||
736 | return 1; | 737 | return 1; |
737 | } | 738 | } |
@@ -740,6 +741,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
740 | { | 741 | { |
741 | ide_hwif_t *hwif = drive->hwif; | 742 | ide_hwif_t *hwif = drive->hwif; |
742 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 743 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
744 | u16 *id = drive->id, i; | ||
743 | int error = 0; | 745 | int error = 0; |
744 | u8 stat; | 746 | u8 stat; |
745 | ide_task_t task; | 747 | ide_task_t task; |
@@ -750,7 +752,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
750 | #endif | 752 | #endif |
751 | 753 | ||
752 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ | 754 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ |
753 | if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08)) | 755 | if ((speed & 0xf8) == XFER_PIO_0 && !(drive->driveid->capability & 8)) |
754 | goto skip; | 756 | goto skip; |
755 | 757 | ||
756 | /* | 758 | /* |
@@ -802,9 +804,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
802 | return error; | 804 | return error; |
803 | } | 805 | } |
804 | 806 | ||
805 | drive->id->dma_ultra &= ~0xFF00; | 807 | id[ATA_ID_UDMA_MODES] &= ~0xFF00; |
806 | drive->id->dma_mword &= ~0x0F00; | 808 | id[ATA_ID_MWDMA_MODES] &= ~0x0F00; |
807 | drive->id->dma_1word &= ~0x0F00; | 809 | id[ATA_ID_SWDMA_MODES] &= ~0x0F00; |
808 | 810 | ||
809 | skip: | 811 | skip: |
810 | #ifdef CONFIG_BLK_DEV_IDEDMA | 812 | #ifdef CONFIG_BLK_DEV_IDEDMA |
@@ -814,23 +816,17 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
814 | ide_dma_off_quietly(drive); | 816 | ide_dma_off_quietly(drive); |
815 | #endif | 817 | #endif |
816 | 818 | ||
817 | switch(speed) { | 819 | if (speed >= XFER_UDMA_0) { |
818 | case XFER_UDMA_7: drive->id->dma_ultra |= 0x8080; break; | 820 | i = 1 << (speed - XFER_UDMA_0); |
819 | case XFER_UDMA_6: drive->id->dma_ultra |= 0x4040; break; | 821 | id[ATA_ID_UDMA_MODES] |= (i << 8 | i); |
820 | case XFER_UDMA_5: drive->id->dma_ultra |= 0x2020; break; | 822 | } else if (speed >= XFER_MW_DMA_0) { |
821 | case XFER_UDMA_4: drive->id->dma_ultra |= 0x1010; break; | 823 | i = 1 << (speed - XFER_MW_DMA_0); |
822 | case XFER_UDMA_3: drive->id->dma_ultra |= 0x0808; break; | 824 | id[ATA_ID_MWDMA_MODES] |= (i << 8 | i); |
823 | case XFER_UDMA_2: drive->id->dma_ultra |= 0x0404; break; | 825 | } else if (speed >= XFER_SW_DMA_0) { |
824 | case XFER_UDMA_1: drive->id->dma_ultra |= 0x0202; break; | 826 | i = 1 << (speed - XFER_SW_DMA_0); |
825 | case XFER_UDMA_0: drive->id->dma_ultra |= 0x0101; break; | 827 | id[ATA_ID_SWDMA_MODES] |= (i << 8 | i); |
826 | case XFER_MW_DMA_2: drive->id->dma_mword |= 0x0404; break; | ||
827 | case XFER_MW_DMA_1: drive->id->dma_mword |= 0x0202; break; | ||
828 | case XFER_MW_DMA_0: drive->id->dma_mword |= 0x0101; break; | ||
829 | case XFER_SW_DMA_2: drive->id->dma_1word |= 0x0404; break; | ||
830 | case XFER_SW_DMA_1: drive->id->dma_1word |= 0x0202; break; | ||
831 | case XFER_SW_DMA_0: drive->id->dma_1word |= 0x0101; break; | ||
832 | default: break; | ||
833 | } | 828 | } |
829 | |||
834 | if (!drive->init_speed) | 830 | if (!drive->init_speed) |
835 | drive->init_speed = speed; | 831 | drive->init_speed = speed; |
836 | drive->current_speed = speed; | 832 | drive->current_speed = speed; |
@@ -1035,7 +1031,7 @@ out: | |||
1035 | 1031 | ||
1036 | static void ide_disk_pre_reset(ide_drive_t *drive) | 1032 | static void ide_disk_pre_reset(ide_drive_t *drive) |
1037 | { | 1033 | { |
1038 | int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1; | 1034 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; |
1039 | 1035 | ||
1040 | drive->special.all = 0; | 1036 | drive->special.all = 0; |
1041 | drive->special.b.set_geometry = legacy; | 1037 | drive->special.b.set_geometry = legacy; |