diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2015-01-12 10:56:03 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-01-17 14:25:21 -0800 |
commit | a2c3966d18a93540f49c2c8cc3dda5ce6c9399a7 (patch) | |
tree | 18b59cd3800adbce003db09cc08a95651a97c6d8 /drivers/staging/comedi | |
parent | 16d87782c560fac81627ddc9368b4f7100a1c2f7 (diff) |
staging: comedi: pcl816: 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 <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r-- | drivers/staging/comedi/Kconfig | 2 | ||||
-rw-r--r-- | 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 c48ee226724b..59c17e60b0be 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 49c1f170f082..1b760858c72a 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); } } |