staging: comedi: pcl818: introduce pcl818_isadma_disable()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 13 Jan 2015 17:16:21 +0000 (10:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 22:31:29 +0000 (14:31 -0800)
According to Documentation/DMA-ISA-LPC.txt, the DMA lock needs to be
claimed before using any of the ISA DMA routines. Introduce a helper
function to disable the ISA DMA controller and add the necessary
locking calls.

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>
drivers/staging/comedi/drivers/pcl818.c

index 4f5f4e94ae0f0cf00444db66f05868f923bc22f3..a1279c24afb949a06e31269a89deb9ea84a5da25 100644 (file)
@@ -342,6 +342,15 @@ static void pcl818_isadma_program(unsigned int dma_chan,
        release_dma_lock(flags);
 }
 
+static void pcl818_isadma_disable(unsigned int dma_chan)
+{
+       unsigned long flags;
+
+       flags = claim_dma_lock();
+       disable_dma(dma_chan);
+       release_dma_lock(flags);
+}
+
 static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters)
 {
        struct pcl818_private *devpriv = dev->private;
@@ -364,7 +373,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev,
        struct pcl818_dma_desc *dma = &devpriv->dma_desc[0];
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       disable_dma(devpriv->dma);      /*  disable dma */
+       pcl818_isadma_disable(devpriv->dma);
        if (cmd->stop_src == TRIG_COUNT) {
                dma->size = cmd->stop_arg * comedi_bytes_per_scan(s);
                devpriv->dma_runs_to_end = dma->size / devpriv->hwdmasize;
@@ -388,7 +397,7 @@ static void pcl818_ai_setup_next_dma(struct comedi_device *dev,
        struct comedi_cmd *cmd = &s->async->cmd;
        struct pcl818_dma_desc *dma;
 
-       disable_dma(devpriv->dma);
+       pcl818_isadma_disable(devpriv->dma);
        devpriv->cur_dma = 1 - devpriv->cur_dma;
        if (devpriv->dma_runs_to_end > -1 || cmd->stop_src == TRIG_NONE) {
                /* switch dma bufs */
@@ -879,7 +888,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
                                return 0;
                        }
                }
-               disable_dma(devpriv->dma);
+               pcl818_isadma_disable(devpriv->dma);
        }
 
        outb(PCL818_CTRL_DISABLE_TRIG, dev->iobase + PCL818_CTRL_REG);