diff options
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r-- | drivers/ide/ide-dma.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 244b61b573ce..3f949b5db353 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -844,36 +844,43 @@ void ide_dma_timeout(ide_drive_t *drive) | |||
844 | } | 844 | } |
845 | EXPORT_SYMBOL_GPL(ide_dma_timeout); | 845 | EXPORT_SYMBOL_GPL(ide_dma_timeout); |
846 | 846 | ||
847 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | ||
848 | void ide_release_dma_engine(ide_hwif_t *hwif) | 847 | void ide_release_dma_engine(ide_hwif_t *hwif) |
849 | { | 848 | { |
850 | if (hwif->dmatable_cpu) { | 849 | if (hwif->dmatable_cpu) { |
851 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 850 | int prd_size = hwif->prd_max_nents * hwif->prd_ent_size; |
852 | 851 | ||
853 | pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES, | 852 | dma_free_coherent(hwif->dev, prd_size, |
854 | hwif->dmatable_cpu, hwif->dmatable_dma); | 853 | hwif->dmatable_cpu, hwif->dmatable_dma); |
855 | hwif->dmatable_cpu = NULL; | 854 | hwif->dmatable_cpu = NULL; |
856 | } | 855 | } |
857 | } | 856 | } |
857 | EXPORT_SYMBOL_GPL(ide_release_dma_engine); | ||
858 | 858 | ||
859 | int ide_allocate_dma_engine(ide_hwif_t *hwif) | 859 | int ide_allocate_dma_engine(ide_hwif_t *hwif) |
860 | { | 860 | { |
861 | struct pci_dev *pdev = to_pci_dev(hwif->dev); | 861 | int prd_size; |
862 | 862 | ||
863 | hwif->dmatable_cpu = pci_alloc_consistent(pdev, | 863 | if (hwif->prd_max_nents == 0) |
864 | PRD_ENTRIES * PRD_BYTES, | 864 | hwif->prd_max_nents = PRD_ENTRIES; |
865 | &hwif->dmatable_dma); | 865 | if (hwif->prd_ent_size == 0) |
866 | hwif->prd_ent_size = PRD_BYTES; | ||
866 | 867 | ||
867 | if (hwif->dmatable_cpu) | 868 | prd_size = hwif->prd_max_nents * hwif->prd_ent_size; |
868 | return 0; | ||
869 | 869 | ||
870 | printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", | 870 | hwif->dmatable_cpu = dma_alloc_coherent(hwif->dev, prd_size, |
871 | &hwif->dmatable_dma, | ||
872 | GFP_ATOMIC); | ||
873 | if (hwif->dmatable_cpu == NULL) { | ||
874 | printk(KERN_ERR "%s: unable to allocate PRD table\n", | ||
871 | hwif->name); | 875 | hwif->name); |
876 | return -ENOMEM; | ||
877 | } | ||
872 | 878 | ||
873 | return 1; | 879 | return 0; |
874 | } | 880 | } |
875 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); | 881 | EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); |
876 | 882 | ||
883 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | ||
877 | const struct ide_dma_ops sff_dma_ops = { | 884 | const struct ide_dma_ops sff_dma_ops = { |
878 | .dma_host_set = ide_dma_host_set, | 885 | .dma_host_set = ide_dma_host_set, |
879 | .dma_setup = ide_dma_setup, | 886 | .dma_setup = ide_dma_setup, |