From 4d052d4d877cfc8edfde30935ae0143a6e7a2942 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 18 Jul 2011 12:08:38 +0100 Subject: [PATCH] ni_pcidio: Grab MITE channel spinlock while preparing and arming DMA. 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 --- comedi/drivers/ni_pcidio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/comedi/drivers/ni_pcidio.c b/comedi/drivers/ni_pcidio.c index b39a2cf8..1e66cd43 100644 --- a/comedi/drivers/ni_pcidio.c +++ b/comedi/drivers/ni_pcidio.c @@ -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, -- 2.26.2