diff options
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r-- | drivers/ide/ide-dma.c | 53 |
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 5fe85191d49c..b77b7d138c49 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -670,41 +670,6 @@ int __ide_dma_good_drive (ide_drive_t *drive) | |||
670 | 670 | ||
671 | EXPORT_SYMBOL(__ide_dma_good_drive); | 671 | EXPORT_SYMBOL(__ide_dma_good_drive); |
672 | 672 | ||
673 | int ide_use_dma(ide_drive_t *drive) | ||
674 | { | ||
675 | struct hd_driveid *id = drive->id; | ||
676 | ide_hwif_t *hwif = drive->hwif; | ||
677 | |||
678 | if ((id->capability & 1) == 0 || drive->autodma == 0) | ||
679 | return 0; | ||
680 | |||
681 | /* consult the list of known "bad" drives */ | ||
682 | if (__ide_dma_bad_drive(drive)) | ||
683 | return 0; | ||
684 | |||
685 | /* capable of UltraDMA modes */ | ||
686 | if (id->field_valid & 4) { | ||
687 | if (hwif->ultra_mask & id->dma_ultra) | ||
688 | return 1; | ||
689 | } | ||
690 | |||
691 | /* capable of regular DMA modes */ | ||
692 | if (id->field_valid & 2) { | ||
693 | if (hwif->mwdma_mask & id->dma_mword) | ||
694 | return 1; | ||
695 | if (hwif->swdma_mask & id->dma_1word) | ||
696 | return 1; | ||
697 | } | ||
698 | |||
699 | /* consult the list of known "good" drives */ | ||
700 | if (__ide_dma_good_drive(drive) && id->eide_dma_time < 150) | ||
701 | return 1; | ||
702 | |||
703 | return 0; | ||
704 | } | ||
705 | |||
706 | EXPORT_SYMBOL_GPL(ide_use_dma); | ||
707 | |||
708 | static const u8 xfer_mode_bases[] = { | 673 | static const u8 xfer_mode_bases[] = { |
709 | XFER_UDMA_0, | 674 | XFER_UDMA_0, |
710 | XFER_MW_DMA_0, | 675 | XFER_MW_DMA_0, |
@@ -731,10 +696,12 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base) | |||
731 | mask &= 0x07; | 696 | mask &= 0x07; |
732 | break; | 697 | break; |
733 | case XFER_MW_DMA_0: | 698 | case XFER_MW_DMA_0: |
734 | mask = id->dma_mword & hwif->mwdma_mask; | 699 | if (id->field_valid & 2) |
700 | mask = id->dma_mword & hwif->mwdma_mask; | ||
735 | break; | 701 | break; |
736 | case XFER_SW_DMA_0: | 702 | case XFER_SW_DMA_0: |
737 | mask = id->dma_1word & hwif->swdma_mask; | 703 | if (id->field_valid & 2) |
704 | mask = id->dma_1word & hwif->swdma_mask; | ||
738 | break; | 705 | break; |
739 | default: | 706 | default: |
740 | BUG(); | 707 | BUG(); |
@@ -783,8 +750,11 @@ int ide_tune_dma(ide_drive_t *drive) | |||
783 | { | 750 | { |
784 | u8 speed; | 751 | u8 speed; |
785 | 752 | ||
786 | /* TODO: use only ide_max_dma_mode() */ | 753 | if ((drive->id->capability & 1) == 0 || drive->autodma == 0) |
787 | if (!ide_use_dma(drive)) | 754 | return 0; |
755 | |||
756 | /* consult the list of known "bad" drives */ | ||
757 | if (__ide_dma_bad_drive(drive)) | ||
788 | return 0; | 758 | return 0; |
789 | 759 | ||
790 | speed = ide_max_dma_mode(drive); | 760 | speed = ide_max_dma_mode(drive); |
@@ -792,9 +762,10 @@ int ide_tune_dma(ide_drive_t *drive) | |||
792 | if (!speed) | 762 | if (!speed) |
793 | return 0; | 763 | return 0; |
794 | 764 | ||
795 | drive->hwif->speedproc(drive, speed); | 765 | if (drive->hwif->speedproc(drive, speed)) |
766 | return 0; | ||
796 | 767 | ||
797 | return ide_dma_enable(drive); | 768 | return 1; |
798 | } | 769 | } |
799 | 770 | ||
800 | EXPORT_SYMBOL_GPL(ide_tune_dma); | 771 | EXPORT_SYMBOL_GPL(ide_tune_dma); |