From: H Hartley Sweeten Date: Mon, 12 Jan 2015 17:56:11 +0000 (-0700) Subject: staging: comedi: dt282x: remove VIRT_TO_BUS dependancy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ef98a104c2ffa885de4e5bb76fb2e80fa677f7c5;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git staging: comedi: dt282x: 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 4441600057e0..37f33c461701 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -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, diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 8ee61861f7ae..f24ad6684bf5 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -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); } }