Commit a2c3966d authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 16d87782
...@@ -179,7 +179,7 @@ config COMEDI_PCL812 ...@@ -179,7 +179,7 @@ config COMEDI_PCL812
config COMEDI_PCL816 config COMEDI_PCL816
tristate "Advantech PCL-814 and PCL-816 ISA card support" tristate "Advantech PCL-814 and PCL-816 ISA card support"
depends on VIRT_TO_BUS && ISA_DMA_API depends on ISA_DMA_API
---help--- ---help---
Enable support for Advantech PCL-814 and PCL-816 ISA cards Enable support for Advantech PCL-814 and PCL-816 ISA cards
......
...@@ -114,13 +114,12 @@ static const struct pcl816_board boardtypes[] = { ...@@ -114,13 +114,12 @@ static const struct pcl816_board boardtypes[] = {
}; };
struct pcl816_dma_desc { struct pcl816_dma_desc {
unsigned long virt_addr; /* virtual address of DMA buffer */ void *virt_addr; /* virtual address of DMA buffer */
unsigned int hw_addr; /* hardware (bus) address of DMA buffer */ dma_addr_t hw_addr; /* hardware (bus) address of DMA buffer */
}; };
struct pcl816_private { struct pcl816_private {
unsigned int dma; /* used DMA, 0=don't use DMA */ unsigned int dma; /* used DMA, 0=don't use DMA */
unsigned int dmapages;
unsigned int hwdmasize; unsigned int hwdmasize;
struct pcl816_dma_desc dma_desc[2]; struct pcl816_dma_desc dma_desc[2];
int cur_dma; int cur_dma;
...@@ -345,8 +344,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d) ...@@ -345,8 +344,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
bufptr = devpriv->ai_poll_ptr; bufptr = devpriv->ai_poll_ptr;
devpriv->ai_poll_ptr = 0; devpriv->ai_poll_ptr = 0;
transfer_from_dma_buf(dev, s, (unsigned short *)dma->virt_addr, transfer_from_dma_buf(dev, s, dma->virt_addr, bufptr, len);
bufptr, len);
pcl816_ai_clear_eoc(dev); pcl816_ai_clear_eoc(dev);
...@@ -552,7 +550,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -552,7 +550,7 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s)
return 0; 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, top2);
devpriv->ai_poll_ptr = top1; /* new buffer position */ devpriv->ai_poll_ptr = top1; /* new buffer position */
...@@ -693,16 +691,15 @@ static int pcl816_alloc_dma(struct comedi_device *dev, ...@@ -693,16 +691,15 @@ static int pcl816_alloc_dma(struct comedi_device *dev,
dev->irq = irq_num; dev->irq = irq_num;
devpriv->dma = dma_chan; devpriv->dma = dma_chan;
devpriv->dmapages = 2; /* we need 16KB */ devpriv->hwdmasize = PAGE_SIZE * 4; /* we need 16KB */
devpriv->hwdmasize = (1 << devpriv->dmapages) * PAGE_SIZE;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
dma = &devpriv->dma_desc[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) if (!dma->virt_addr)
return -ENOMEM; return -ENOMEM;
dma->hw_addr = virt_to_bus((void *)dma->virt_addr);
} }
return 0; return 0;
} }
...@@ -721,7 +718,8 @@ static void pcl816_free_dma(struct comedi_device *dev) ...@@ -721,7 +718,8 @@ static void pcl816_free_dma(struct comedi_device *dev)
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
dma = &devpriv->dma_desc[i]; dma = &devpriv->dma_desc[i];
if (dma->virt_addr) if (dma->virt_addr)
free_pages(dma->virt_addr, devpriv->dmapages); dma_free_coherent(NULL, devpriv->hwdmasize,
dma->virt_addr, dma->hw_addr);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment