[PATCH 25/37] staging: comedi: pcl816: 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/pcl816.c | 20 +++++++++-----------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index c48ee22..59c17e6 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -179,7 +179,7 @@ config COMEDI_PCL812
 
 config COMEDI_PCL816
 	tristate "Advantech PCL-814 and PCL-816 ISA card support"
-	depends on VIRT_TO_BUS && ISA_DMA_API
+	depends on ISA_DMA_API
 	---help---
 	  Enable support for Advantech PCL-814 and PCL-816 ISA cards
 
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 49c1f17..1b76085 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -114,13 +114,12 @@ static const struct pcl816_board boardtypes[] = {
 };
 
 struct pcl816_dma_desc {
-	unsigned long virt_addr;	/* virtual address of DMA buffer */
-	unsigned int hw_addr;	/* hardware (bus) address of DMA buffer */
+	void *virt_addr;	/* virtual address of DMA buffer */
+	dma_addr_t hw_addr;	/* hardware (bus) address of DMA buffer */
 };
 
 struct pcl816_private {
 	unsigned int dma;	/*  used DMA, 0=don't use DMA */
-	unsigned int dmapages;
 	unsigned int hwdmasize;
 	struct pcl816_dma_desc dma_desc[2];
 	int cur_dma;
@@ -345,8 +344,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
 	bufptr = devpriv->ai_poll_ptr;
 	devpriv->ai_poll_ptr = 0;
 
-	transfer_from_dma_buf(dev, s, (unsigned short *)dma->virt_addr,
-			      bufptr, len);
+	transfer_from_dma_buf(dev, s, dma->virt_addr, bufptr, len);
 
 	pcl816_ai_clear_eoc(dev);
 
@@ -552,7 +550,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
 		return 0;
 	}
 
-	transfer_from_dma_buf(dev, s, (unsigned short *)dma->virt_addr,
+	transfer_from_dma_buf(dev, s, dma->virt_addr,
 			      devpriv->ai_poll_ptr, top2);
 
 	devpriv->ai_poll_ptr = top1;	/*  new buffer position */
@@ -693,16 +691,15 @@ static int pcl816_alloc_dma(struct comedi_device *dev,
 	dev->irq = irq_num;
 	devpriv->dma = dma_chan;
 
-	devpriv->dmapages = 2;	/* we need 16KB */
-	devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE;
+	devpriv->hwdmasize = PAGE_SIZE * 4;	/* we need 16KB */
 
 	for (i = 0; i < 2; i++) {
 		dma = &devpriv->dma_desc[i];
 
-		dma->virt_addr = __get_dma_pages(GFP_KERNEL, devpriv->dmapages);
+		dma->virt_addr = dma_alloc_coherent(NULL, devpriv->hwdmasize,
+						    &dma->hw_addr, GFP_KERNEL);
 		if (!dma->virt_addr)
 			return -ENOMEM;
-		dma->hw_addr = virt_to_bus((void *)dma->virt_addr);
 	}
 	return 0;
 }
@@ -721,7 +718,8 @@ static void pcl816_free_dma(struct comedi_device *dev)
 	for (i = 0; i < 2; i++) {
 		dma = &devpriv->dma_desc[i];
 		if (dma->virt_addr)
-			free_pages(dma->virt_addr, devpriv->dmapages);
+			dma_free_coherent(NULL, devpriv->hwdmasize,
+					  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