ni_pcidio: Grab MITE channel spinlock while preparing and arming DMA.
authorIan Abbott <abbotti@mev.co.uk>
Mon, 18 Jul 2011 11:08:38 +0000 (12:08 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Mon, 18 Jul 2011 11:08:38 +0000 (12:08 +0100)
When setting up the DMA for 'read' streaming acquisition command, grab
the MITE channel spinlock before preparing and arming the DMA.

Change inspired by ni_ai_setup_MITE_dma() in ni_mio_common.c.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
comedi/drivers/ni_pcidio.c

index b39a2cf8ae1b75494e3ebd97ccb6e770aa483c64..1e66cd4393479da2ba4c4238b8b33cd17ba3e75a 100644 (file)
@@ -1000,10 +1000,16 @@ static int setup_mite_dma(comedi_device * dev, comedi_subdevice * s)
        /* write alloc the entire buffer */
        comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz);
 
-       mite_prep_dma(devpriv->di_mite_chan, 32, 32);
+       comedi_spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+       if (devpriv->di_mite_chan) {
+               mite_prep_dma(devpriv->di_mite_chan, 32, 32);
 
-       mite_dma_arm(devpriv->di_mite_chan);
-       return 0;
+               mite_dma_arm(devpriv->di_mite_chan);
+       } else
+               retval = -EIO;
+       comedi_spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+
+       return retval;
 }
 
 static int ni_pcidio_inttrig(comedi_device * dev, comedi_subdevice * s,