aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-dma.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:47 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:47 -0400
commit2bbd57cad3d72334c9fcc4e229a5a5b04dc6aebc (patch)
treec0866cb7b4a3e12d11179c65d86e2ba012db5002 /drivers/ide/ide-dma.c
parentffa15a6915b7f6f6f69b4a66e1100a9c68d11250 (diff)
ide: switch to DMA-mapping API part #2
Follow-up to commit 5c05ff68b9a9b40a9be949497e0aa980185565cf ("ide: switch to DMA-mapping API"): * pci_{alloc,free}_consistent() -> dma_{alloc,free}_coherent() in ide_{allocate,release}_dma_engine(). * Add ->prd_max_nents and ->prd_ent_size fields to ide_hwif_t (+ set default values in ide_allocate_dma_engine()). * Make ide_{allocate,release}_dma_engine() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n. Then convert au1xxx-ide.c, scc_pata.c and sgiioc4.c to use them. * Add missing ->init_dma method to scc_pata. This patch also fixes: - ->dmatable_cpu leak for au1xxx-ide - too early realease of ->dmatable_cpu for scc_pata - wrong amount of ->dmatable_cpu memory being freed for sgiioc4 While at it: - remove superfluous ->dma_base check from ide_unregister() - return -ENOMEM on error in ide_release_dma_engine() - beautify error message in ide_release_dma_engine() Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-dma.c')
-rw-r--r--drivers/ide/ide-dma.c31
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}
845EXPORT_SYMBOL_GPL(ide_dma_timeout); 845EXPORT_SYMBOL_GPL(ide_dma_timeout);
846 846
847#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
848void ide_release_dma_engine(ide_hwif_t *hwif) 847void 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}
857EXPORT_SYMBOL_GPL(ide_release_dma_engine);
858 858
859int ide_allocate_dma_engine(ide_hwif_t *hwif) 859int 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}
875EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); 881EXPORT_SYMBOL_GPL(ide_allocate_dma_engine);
876 882
883#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
877const struct ide_dma_ops sff_dma_ops = { 884const 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,