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

staging: comedi: das1800: introduce das1800_free_dma()

For aesthetics, introduce a helper function to free the DMA channels and
allocated buffers.
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 a4b064ee
...@@ -1303,6 +1303,25 @@ static int das1800_init_dma(struct comedi_device *dev, ...@@ -1303,6 +1303,25 @@ static int das1800_init_dma(struct comedi_device *dev,
return 0; return 0;
} }
static void das1800_free_dma(struct comedi_device *dev)
{
struct das1800_private *devpriv = dev->private;
struct das1800_dma_desc *dma;
int i;
if (!devpriv)
return;
for (i = 0; i < 2; i++) {
dma = &devpriv->dma_desc[i];
if (dma->chan)
free_dma(dma->chan);
if (dma->virt_addr)
dma_free_coherent(NULL, DMA_BUF_SIZE,
dma->virt_addr, dma->hw_addr);
}
}
static int das1800_probe(struct comedi_device *dev) static int das1800_probe(struct comedi_device *dev)
{ {
const struct das1800_board *board = dev->board_ptr; const struct das1800_board *board = dev->board_ptr;
...@@ -1514,18 +1533,9 @@ static int das1800_attach(struct comedi_device *dev, ...@@ -1514,18 +1533,9 @@ static int das1800_attach(struct comedi_device *dev,
static void das1800_detach(struct comedi_device *dev) static void das1800_detach(struct comedi_device *dev)
{ {
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
struct das1800_dma_desc *dma;
int i;
das1800_free_dma(dev);
if (devpriv) { if (devpriv) {
for (i = 0; i < 2; i++) {
dma = &devpriv->dma_desc[i];
if (dma->chan)
free_dma(dma->chan);
if (dma->virt_addr)
dma_free_coherent(NULL, DMA_BUF_SIZE,
dma->virt_addr, dma->hw_addr);
}
kfree(devpriv->fifo_buf); kfree(devpriv->fifo_buf);
if (devpriv->iobase2) if (devpriv->iobase2)
release_region(devpriv->iobase2, DAS1800_SIZE); release_region(devpriv->iobase2, DAS1800_SIZE);
......
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