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

staging: comedi: pcl818: 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 b8e7048b
...@@ -188,7 +188,7 @@ config COMEDI_PCL816 ...@@ -188,7 +188,7 @@ config COMEDI_PCL816
config COMEDI_PCL818 config COMEDI_PCL818
tristate "Advantech PCL-718 and PCL-818 ISA card support" tristate "Advantech PCL-718 and PCL-818 ISA card support"
depends on VIRT_TO_BUS && ISA_DMA_API depends on ISA_DMA_API
---help--- ---help---
Enable support for Advantech PCL-818 ISA cards Enable support for Advantech PCL-818 ISA cards
PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718 PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718
......
...@@ -303,13 +303,12 @@ static const struct pcl818_board boardtypes[] = { ...@@ -303,13 +303,12 @@ static const struct pcl818_board boardtypes[] = {
}; };
struct pcl818_dma_desc { struct pcl818_dma_desc {
unsigned long dmabuf; /* pointers to begin of DMA buffers */ void *virt_addr; /* virtual address of DMA buffer */
unsigned int hwdmaptr; /* hardware address of DMA buffers */ dma_addr_t hw_addr; /* hardware (bus) address of DMA buffer */
}; };
struct pcl818_private { struct pcl818_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 pcl818_dma_desc dma_desc[2]; struct pcl818_dma_desc dma_desc[2];
int cur_dma; int cur_dma;
...@@ -367,7 +366,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev, ...@@ -367,7 +366,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev,
set_dma_mode(devpriv->dma, DMA_MODE_READ); set_dma_mode(devpriv->dma, DMA_MODE_READ);
flags = claim_dma_lock(); flags = claim_dma_lock();
clear_dma_ff(devpriv->dma); clear_dma_ff(devpriv->dma);
set_dma_addr(devpriv->dma, dma->hwdmaptr); set_dma_addr(devpriv->dma, dma->hw_addr);
set_dma_count(devpriv->dma, bytes); set_dma_count(devpriv->dma, bytes);
release_dma_lock(flags); release_dma_lock(flags);
enable_dma(devpriv->dma); enable_dma(devpriv->dma);
...@@ -388,7 +387,7 @@ static void pcl818_ai_setup_next_dma(struct comedi_device *dev, ...@@ -388,7 +387,7 @@ static void pcl818_ai_setup_next_dma(struct comedi_device *dev,
dma = &devpriv->dma_desc[devpriv->cur_dma]; dma = &devpriv->dma_desc[devpriv->cur_dma];
set_dma_mode(devpriv->dma, DMA_MODE_READ); set_dma_mode(devpriv->dma, DMA_MODE_READ);
flags = claim_dma_lock(); flags = claim_dma_lock();
set_dma_addr(devpriv->dma, dma->hwdmaptr); set_dma_addr(devpriv->dma, dma->hw_addr);
if (devpriv->dma_runs_to_end || cmd->stop_src == TRIG_NONE) if (devpriv->dma_runs_to_end || cmd->stop_src == TRIG_NONE)
set_dma_count(devpriv->dma, devpriv->hwdmasize); set_dma_count(devpriv->dma, devpriv->hwdmasize);
else else
...@@ -565,7 +564,7 @@ static void pcl818_handle_dma(struct comedi_device *dev, ...@@ -565,7 +564,7 @@ static void pcl818_handle_dma(struct comedi_device *dev,
{ {
struct pcl818_private *devpriv = dev->private; struct pcl818_private *devpriv = dev->private;
struct pcl818_dma_desc *dma = &devpriv->dma_desc[devpriv->cur_dma]; struct pcl818_dma_desc *dma = &devpriv->dma_desc[devpriv->cur_dma];
unsigned short *ptr = (unsigned short *)dma->dmabuf; unsigned short *ptr = dma->virt_addr;
unsigned int chan; unsigned int chan;
unsigned int val; unsigned int val;
int i, len, bufptr; int i, len, bufptr;
...@@ -1072,16 +1071,15 @@ static int pcl818_alloc_dma(struct comedi_device *dev, unsigned int dma_chan) ...@@ -1072,16 +1071,15 @@ static int pcl818_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
return 0; return 0;
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->dmabuf = __get_dma_pages(GFP_KERNEL, devpriv->dmapages); dma->virt_addr = dma_alloc_coherent(NULL, devpriv->hwdmasize,
if (!dma->dmabuf) &dma->hw_addr, GFP_KERNEL);
if (!dma->virt_addr)
return -ENOMEM; return -ENOMEM;
dma->hwdmaptr = virt_to_bus((void *)dma->dmabuf);
} }
return 0; return 0;
} }
...@@ -1099,8 +1097,9 @@ static void pcl818_free_dma(struct comedi_device *dev) ...@@ -1099,8 +1097,9 @@ static void pcl818_free_dma(struct comedi_device *dev)
free_dma(devpriv->dma); free_dma(devpriv->dma);
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
dma = &devpriv->dma_desc[i]; dma = &devpriv->dma_desc[i];
if (dma->dmabuf) if (dma->virt_addr)
free_pages(dma->dmabuf, 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