From: H Hartley Sweeten Date: Mon, 12 Jan 2015 17:55:44 +0000 (-0700) Subject: staging: comedi: das1800: remove VIRT_TO_BUS dependancy X-Git-Tag: v5.15~16324^2~432 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4b064ee4675686dfe31fcc54c3ec188141f6ee2;p=platform%2Fkernel%2Flinux-starfive.git staging: comedi: das1800: remove VIRT_TO_BUS dependancy 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 1cdbf1f..fe030a3 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -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, diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index df28d36..dd46a91 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -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)