summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-01-12 17:56:01 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-17 22:25:20 (GMT)
commitd7b8bbb6a7c22fd3b830161febfaa89f1d820f09 (patch)
treee303e779c88557c7d7c5cb63c192102eef5d58ed
parent1fa51639e551bee7de73122b8bbafd509eae52fa (diff)
downloadlinux-d7b8bbb6a7c22fd3b830161febfaa89f1d820f09.tar.xz
staging: comedi: pcl816: introduce pcl816_free_dma()
For aesthetics, move the freeing of the DMA channel and the buffers to a helper function. 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>
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 0374f83..4cff02a 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -704,6 +704,22 @@ static int pcl816_alloc_dma(struct comedi_device *dev,
return 0;
}
+static void pcl816_free_dma(struct comedi_device *dev)
+{
+ struct pcl816_private *devpriv = dev->private;
+ int i;
+
+ if (!devpriv)
+ return;
+
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ for (i = 0; i < 2; i++) {
+ if (devpriv->dmabuf[i])
+ free_pages(devpriv->dmabuf[i], devpriv->dmapages);
+ }
+}
+
static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
const struct pcl816_board *board = dev->board_ptr;
@@ -785,18 +801,11 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
static void pcl816_detach(struct comedi_device *dev)
{
- struct pcl816_private *devpriv = dev->private;
-
if (dev->private) {
pcl816_ai_cancel(dev, dev->read_subdev);
pcl816_reset(dev);
- if (devpriv->dma)
- free_dma(devpriv->dma);
- if (devpriv->dmabuf[0])
- free_pages(devpriv->dmabuf[0], devpriv->dmapages);
- if (devpriv->dmabuf[1])
- free_pages(devpriv->dmabuf[1], devpriv->dmapages);
}
+ pcl816_free_dma(dev);
comedi_legacy_detach(dev);
}