[PATCH 33/37] staging: comedi: dt282x: remove VIRT_TO_BUS dependancy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/Kconfig          |  2 +-
 drivers/staging/comedi/drivers/dt282x.c | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 4441600..37f33c4 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 8ee6186..f24ad66 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);
 	}
 }
 
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux