summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2015-01-12 10:55:49 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-17 14:25:19 -0800
commitb1478901b677dd430f4e97989f7f6e2dc8e54556 (patch)
tree60c79f707bdbe4626344166577c27ae39c79d4c8
parent7cbb0ef93a63f7c0574d852607af71f348ccc751 (diff)
staging: comedi: ni_at_a2150: introduce a2150_free_dma()
For aesthetics, introduce a helper function to free the DMA channel and buffer. 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/ni_at_a2150.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index 11b168156a6a..de2e87780de9 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -720,6 +720,18 @@ static void a2150_alloc_irq_dma(struct comedi_device *dev,
set_dma_mode(dma_chan, DMA_MODE_READ);
}
+static void a2150_free_dma(struct comedi_device *dev)
+{
+ struct a2150_private *devpriv = dev->private;
+
+ if (!devpriv)
+ return;
+
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ kfree(devpriv->dma_buffer);
+}
+
/* probes board type, returns offset */
static int a2150_probe(struct comedi_device *dev)
{
@@ -808,15 +820,9 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
static void a2150_detach(struct comedi_device *dev)
{
- struct a2150_private *devpriv = dev->private;
-
if (dev->iobase)
outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
- if (devpriv) {
- if (devpriv->dma)
- free_dma(devpriv->dma);
- kfree(devpriv->dma_buffer);
- }
+ a2150_free_dma(dev);
comedi_legacy_detach(dev);
};