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-dma.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-dma.c')
-rw-r--r-- | drivers/ide/ide-dma.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 3fa07c0aeaa4..abab26de7687 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable); | |||
288 | static int config_drive_for_dma (ide_drive_t *drive) | 288 | static int config_drive_for_dma (ide_drive_t *drive) |
289 | { | 289 | { |
290 | ide_hwif_t *hwif = drive->hwif; | 290 | ide_hwif_t *hwif = drive->hwif; |
291 | struct hd_driveid *id = drive->id; | 291 | u16 *id = drive->id; |
292 | 292 | ||
293 | if (drive->media != ide_disk) { | 293 | if (drive->media != ide_disk) { |
294 | if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) | 294 | if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) |
@@ -299,16 +299,17 @@ static int config_drive_for_dma (ide_drive_t *drive) | |||
299 | * Enable DMA on any drive that has | 299 | * Enable DMA on any drive that has |
300 | * UltraDMA (mode 0/1/2/3/4/5/6) enabled | 300 | * UltraDMA (mode 0/1/2/3/4/5/6) enabled |
301 | */ | 301 | */ |
302 | if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) | 302 | if ((id[ATA_ID_FIELD_VALID] & 4) && |
303 | ((id[ATA_ID_UDMA_MODES] >> 8) & 0x7f)) | ||
303 | return 1; | 304 | return 1; |
304 | 305 | ||
305 | /* | 306 | /* |
306 | * Enable DMA on any drive that has mode2 DMA | 307 | * Enable DMA on any drive that has mode2 DMA |
307 | * (multi or single) enabled | 308 | * (multi or single) enabled |
308 | */ | 309 | */ |
309 | if (id->field_valid & 2) /* regular DMA */ | 310 | if (id[ATA_ID_FIELD_VALID] & 2) /* regular DMA */ |
310 | if ((id->dma_mword & 0x404) == 0x404 || | 311 | if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 || |
311 | (id->dma_1word & 0x404) == 0x404) | 312 | (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404) |
312 | return 1; | 313 | return 1; |
313 | 314 | ||
314 | /* Consult the list of known "good" drives */ | 315 | /* Consult the list of known "good" drives */ |
@@ -591,12 +592,12 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | |||
591 | 592 | ||
592 | int __ide_dma_bad_drive (ide_drive_t *drive) | 593 | int __ide_dma_bad_drive (ide_drive_t *drive) |
593 | { | 594 | { |
594 | struct hd_driveid *id = drive->id; | 595 | u16 *id = drive->id; |
595 | 596 | ||
596 | int blacklist = ide_in_drive_list(id, drive_blacklist); | 597 | int blacklist = ide_in_drive_list(id, drive_blacklist); |
597 | if (blacklist) { | 598 | if (blacklist) { |
598 | printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", | 599 | printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", |
599 | drive->name, id->model); | 600 | drive->name, (char *)&id[ATA_ID_PROD]); |
600 | return blacklist; | 601 | return blacklist; |
601 | } | 602 | } |
602 | return 0; | 603 | return 0; |
@@ -612,21 +613,21 @@ static const u8 xfer_mode_bases[] = { | |||
612 | 613 | ||
613 | static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | 614 | static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) |
614 | { | 615 | { |
615 | struct hd_driveid *id = drive->id; | 616 | u16 *id = drive->id; |
616 | ide_hwif_t *hwif = drive->hwif; | 617 | ide_hwif_t *hwif = drive->hwif; |
617 | const struct ide_port_ops *port_ops = hwif->port_ops; | 618 | const struct ide_port_ops *port_ops = hwif->port_ops; |
618 | unsigned int mask = 0; | 619 | unsigned int mask = 0; |
619 | 620 | ||
620 | switch(base) { | 621 | switch(base) { |
621 | case XFER_UDMA_0: | 622 | case XFER_UDMA_0: |
622 | if ((id->field_valid & 4) == 0) | 623 | if ((id[ATA_ID_FIELD_VALID] & 4) == 0) |
623 | break; | 624 | break; |
624 | 625 | ||
625 | if (port_ops && port_ops->udma_filter) | 626 | if (port_ops && port_ops->udma_filter) |
626 | mask = port_ops->udma_filter(drive); | 627 | mask = port_ops->udma_filter(drive); |
627 | else | 628 | else |
628 | mask = hwif->ultra_mask; | 629 | mask = hwif->ultra_mask; |
629 | mask &= id->dma_ultra; | 630 | mask &= id[ATA_ID_UDMA_MODES]; |
630 | 631 | ||
631 | /* | 632 | /* |
632 | * avoid false cable warning from eighty_ninty_three() | 633 | * avoid false cable warning from eighty_ninty_three() |
@@ -637,19 +638,19 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
637 | } | 638 | } |
638 | break; | 639 | break; |
639 | case XFER_MW_DMA_0: | 640 | case XFER_MW_DMA_0: |
640 | if ((id->field_valid & 2) == 0) | 641 | if ((id[ATA_ID_FIELD_VALID] & 2) == 0) |
641 | break; | 642 | break; |
642 | if (port_ops && port_ops->mdma_filter) | 643 | if (port_ops && port_ops->mdma_filter) |
643 | mask = port_ops->mdma_filter(drive); | 644 | mask = port_ops->mdma_filter(drive); |
644 | else | 645 | else |
645 | mask = hwif->mwdma_mask; | 646 | mask = hwif->mwdma_mask; |
646 | mask &= id->dma_mword; | 647 | mask &= id[ATA_ID_MWDMA_MODES]; |
647 | break; | 648 | break; |
648 | case XFER_SW_DMA_0: | 649 | case XFER_SW_DMA_0: |
649 | if (id->field_valid & 2) { | 650 | if (id[ATA_ID_FIELD_VALID] & 2) { |
650 | mask = id->dma_1word & hwif->swdma_mask; | 651 | mask = id[ATA_ID_SWDMA_MODES] & hwif->swdma_mask; |
651 | } else if (id->tDMA) { | 652 | } else if (drive->driveid->tDMA) { |
652 | u8 mode = id->tDMA; | 653 | u8 mode = drive->driveid->tDMA; |
653 | 654 | ||
654 | /* | 655 | /* |
655 | * if the mode is valid convert it to the mask | 656 | * if the mode is valid convert it to the mask |
@@ -706,7 +707,8 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode) | |||
706 | /* | 707 | /* |
707 | * is this correct? | 708 | * is this correct? |
708 | */ | 709 | */ |
709 | if (ide_dma_good_drive(drive) && drive->id->eide_dma_time < 150) | 710 | if (ide_dma_good_drive(drive) && |
711 | drive->id[ATA_ID_EIDE_DMA_TIME] < 150) | ||
710 | mode = XFER_MW_DMA_1; | 712 | mode = XFER_MW_DMA_1; |
711 | } | 713 | } |
712 | 714 | ||
@@ -725,7 +727,7 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
725 | ide_hwif_t *hwif = drive->hwif; | 727 | ide_hwif_t *hwif = drive->hwif; |
726 | u8 speed; | 728 | u8 speed; |
727 | 729 | ||
728 | if (drive->nodma || (drive->id->capability & 1) == 0) | 730 | if (drive->nodma || (drive->driveid->capability & 1) == 0) |
729 | return 0; | 731 | return 0; |
730 | 732 | ||
731 | /* consult the list of known "bad" drives */ | 733 | /* consult the list of known "bad" drives */ |
@@ -767,13 +769,15 @@ static int ide_dma_check(ide_drive_t *drive) | |||
767 | 769 | ||
768 | int ide_id_dma_bug(ide_drive_t *drive) | 770 | int ide_id_dma_bug(ide_drive_t *drive) |
769 | { | 771 | { |
770 | struct hd_driveid *id = drive->id; | 772 | u16 *id = drive->id; |
771 | 773 | ||
772 | if (id->field_valid & 4) { | 774 | if (id[ATA_ID_FIELD_VALID] & 4) { |
773 | if ((id->dma_ultra >> 8) && (id->dma_mword >> 8)) | 775 | if ((id[ATA_ID_UDMA_MODES] >> 8) && |
776 | (id[ATA_ID_MWDMA_MODES] >> 8)) | ||
774 | goto err_out; | 777 | goto err_out; |
775 | } else if (id->field_valid & 2) { | 778 | } else if (id[ATA_ID_FIELD_VALID] & 2) { |
776 | if ((id->dma_mword >> 8) && (id->dma_1word >> 8)) | 779 | if ((id[ATA_ID_MWDMA_MODES] >> 8) && |
780 | (id[ATA_ID_SWDMA_MODES] >> 8)) | ||
777 | goto err_out; | 781 | goto err_out; |
778 | } | 782 | } |
779 | return 0; | 783 | return 0; |