staging: comedi: dt282x: remove VIRT_TO_BUS dependancy
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 12 Jan 2015 17:56:11 +0000 (10:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 22:25:21 +0000 (14:25 -0800)
Use dma_{alloc,free}_coherent() to allocate and free the DMA buffers.
This removes the dependancy on VIRT_TO_BUS.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/Kconfig
drivers/staging/comedi/drivers/dt282x.c

index 4441600057e044ab393dbd58b845ba779ded10a8..37f33c461701a128b6c7dc2c25592dd3b16bb116 100644 (file)
@@ -372,7 +372,7 @@ config COMEDI_DT2817
 
 config COMEDI_DT282X
        tristate "Data Translation DT2821 series and DT-EZ ISA card support"
-       depends on VIRT_TO_BUS && ISA_DMA_API
+       depends on ISA_DMA_API
        ---help---
          Enable support for Data Translation DT2821 series including DT-EZ
          DT2821, DT2821-F-16SE, DT2821-F-8DI, DT2821-G-16SE, DT2821-G-8DI,
index 8ee61861f7ae141f9492c6378b9afa4b42c5a655..f24ad6684bf5ddfd0eb32c23dbac3f195c9a4c1e 100644 (file)
@@ -302,7 +302,8 @@ static const struct dt282x_board boardtypes[] = {
 
 struct dt282x_dma_desc {
        unsigned int chan;      /* DMA channel */
-       unsigned short *virt_addr;      /* virtual address of DMA buffer */
+       void *virt_addr;        /* virtual address of DMA buffer */
+       dma_addr_t hw_addr;     /* hardware (bus) address of DMA buffer */
        unsigned int size;      /* transfer size (in bytes) */
 };
 
@@ -344,7 +345,7 @@ static int dt282x_prep_ai_dma(struct comedi_device *dev, int dma_index, int n)
        set_dma_mode(dma->chan, DMA_MODE_READ);
        flags = claim_dma_lock();
        clear_dma_ff(dma->chan);
-       set_dma_addr(dma->chan, virt_to_bus(dma->virt_addr));
+       set_dma_addr(dma->chan, dma->hw_addr);
        set_dma_count(dma->chan, dma->size);
        release_dma_lock(flags);
 
@@ -364,7 +365,7 @@ static int dt282x_prep_ao_dma(struct comedi_device *dev, int dma_index, int n)
        set_dma_mode(dma->chan, DMA_MODE_WRITE);
        flags = claim_dma_lock();
        clear_dma_ff(dma->chan);
-       set_dma_addr(dma->chan, virt_to_bus(dma->virt_addr));
+       set_dma_addr(dma->chan, dma->hw_addr);
        set_dma_count(dma->chan, dma->size);
        release_dma_lock(flags);
 
@@ -1087,7 +1088,8 @@ static int dt282x_alloc_dma(struct comedi_device *dev,
                struct dt282x_dma_desc *dma = &devpriv->dma_desc[i];
 
                dma->chan = dma_chan[i];
-               dma->virt_addr = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+               dma->virt_addr = dma_alloc_coherent(NULL, devpriv->dma_maxsize,
+                                                   &dma->hw_addr, GFP_KERNEL);
                if (!dma->virt_addr)
                        return -ENOMEM;
        }
@@ -1109,7 +1111,8 @@ static void dt282x_free_dma(struct comedi_device *dev)
                if (dma->chan)
                        free_dma(dma->chan);
                if (dma->virt_addr)
-                       free_page((unsigned long)dma->virt_addr);
+                       dma_free_coherent(NULL, devpriv->dma_maxsize,
+                                         dma->virt_addr, dma->hw_addr);
        }
 }