staging: comedi: das1800: remove VIRT_TO_BUS dependancy
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 12 Jan 2015 17:55:44 +0000 (10:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 22:25:19 +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/das1800.c

index 1cdbf1f47c608e6f5977ba1fe6228fa7f1294907..fe030a33d291fd8bde9c38fadfa7e5d2d54c9684 100644 (file)
@@ -309,7 +309,7 @@ config COMEDI_DAS800
 
 config COMEDI_DAS1800
        tristate "DAS1800 and compatible ISA card support"
-       depends on VIRT_TO_BUS && ISA_DMA_API
+       depends on ISA_DMA_API
        ---help---
          Enable support for DAS1800 and compatible ISA cards
          Keithley Metrabyte DAS-1701ST, DAS-1701ST-DA, DAS-1701/AO,
index df28d36aa580421d58fb5b5f08cef1147ec20998..dd46a919904ae762ff57229157bb1a88844c39b3 100644 (file)
@@ -422,7 +422,8 @@ static const struct das1800_board das1800_boards[] = {
 
 struct das1800_dma_desc {
        unsigned int chan;      /* DMA channel */
-       uint16_t *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 */
 };
 
 struct das1800_private {
@@ -572,7 +573,7 @@ static void das1800_handle_dma(struct comedi_device *dev,
        flags = claim_dma_lock();
        das1800_flush_dma_channel(dev, s, dma->chan, dma->virt_addr);
        /*  re-enable  dma channel */
-       set_dma_addr(dma->chan, virt_to_bus(dma->virt_addr));
+       set_dma_addr(dma->chan, dma->hw_addr);
        set_dma_count(dma->chan, devpriv->dma_transfer_size);
        enable_dma(dma->chan);
        release_dma_lock(flags);
@@ -1013,7 +1014,7 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
        /* clear flip-flop to make sure 2-byte registers for
         * count and address get set correctly */
        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 appropriate size of transfer */
        set_dma_count(dma->chan, devpriv->dma_transfer_size);
        enable_dma(dma->chan);
@@ -1024,7 +1025,7 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
                /* clear flip-flop to make sure 2-byte registers for
                 * count and address get set correctly */
                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 appropriate size of transfer */
                set_dma_count(dma->chan, devpriv->dma_transfer_size);
                enable_dma(dma->chan);
@@ -1288,7 +1289,8 @@ static int das1800_init_dma(struct comedi_device *dev,
                }
                dma->chan = dma_chan[i];
 
-               dma->virt_addr = kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
+               dma->virt_addr = dma_alloc_coherent(NULL, DMA_BUF_SIZE,
+                                                   &dma->hw_addr, GFP_KERNEL);
                if (!dma->virt_addr)
                        return -ENOMEM;
 
@@ -1520,7 +1522,9 @@ static void das1800_detach(struct comedi_device *dev)
                        dma = &devpriv->dma_desc[i];
                        if (dma->chan)
                                free_dma(dma->chan);
-                       kfree(dma->virt_addr);
+                       if (dma->virt_addr)
+                               dma_free_coherent(NULL, DMA_BUF_SIZE,
+                                                 dma->virt_addr, dma->hw_addr);
                }
                kfree(devpriv->fifo_buf);
                if (devpriv->iobase2)