diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-12-10 02:31:15 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-17 22:02:14 +0400 |
commit | d7c41e83e2c3ae970d41187ae31fad50ccd63856 (patch) | |
tree | 367c183de328d722a4a1735399ab9d778938d4e2 | |
parent | 967e7e5a99cfdbc8a22e491a006875328e9875b1 (diff) | |
download | linux-d7c41e83e2c3ae970d41187ae31fad50ccd63856.tar.xz |
staging: comedi: pcmmio: tidy up pcmmio_handle_dio_intr()
Refactor the code to remove some of the indent levels.
Remove 'mytrig', the shift and mask end up making it the same as 'triggered'
anyway.
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/pcmmio.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 37471bb3d99c..055781dc7875 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -359,50 +359,51 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, unsigned int triggered) { struct pcmmio_private *devpriv = dev->private; + unsigned int oldevents = s->async->events; + unsigned int len = s->async->cmd.chanlist_len; + unsigned int val = 0; unsigned long flags; - unsigned oldevents; + int i; spin_lock_irqsave(&devpriv->spinlock, flags); - oldevents = s->async->events; + if (!devpriv->active) + goto done; - if (devpriv->active) { - unsigned mytrig = ((triggered >> 0) & ((1 << 24) - 1)) << 0; - if (mytrig & devpriv->enabled_mask) { - unsigned int val = 0; - unsigned int n, ch, len; + if (!(triggered & devpriv->enabled_mask)) + goto done; - len = s->async->cmd.chanlist_len; - for (n = 0; n < len; n++) { - ch = CR_CHAN(s->async->cmd.chanlist[n]); - if (mytrig & (1U << ch)) - val |= (1U << n); - } - /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, val) && - comedi_buf_put (s->async, val >> 16)) { - s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); - } else { - /* Overflow! Stop acquisition!! */ + for (i = 0; i < len; i++) { + unsigned int chan = CR_CHAN(s->async->cmd.chanlist[i]); + + if (triggered & (1 << chan)) + val |= (1 << i); + } + + /* Write the scan to the buffer. */ + if (comedi_buf_put(s->async, val) && + comedi_buf_put (s->async, val >> 16)) { + s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); + } else { + /* Overflow! Stop acquisition!! */ + /* TODO: STOP_ACQUISITION_CALL_HERE!! */ + pcmmio_stop_intr(dev, s); + } + + /* Check for end of acquisition. */ + if (!devpriv->continuous) { + /* stop_src == TRIG_COUNT */ + if (devpriv->stop_count > 0) { + devpriv->stop_count--; + if (devpriv->stop_count == 0) { + s->async->events |= COMEDI_CB_EOA; /* TODO: STOP_ACQUISITION_CALL_HERE!! */ pcmmio_stop_intr(dev, s); } - - /* Check for end of acquisition. */ - if (!devpriv->continuous) { - /* stop_src == TRIG_COUNT */ - if (devpriv->stop_count > 0) { - devpriv->stop_count--; - if (devpriv->stop_count == 0) { - s->async->events |= COMEDI_CB_EOA; - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmmio_stop_intr(dev, s); - } - } - } } } +done: spin_unlock_irqrestore(&devpriv->spinlock, flags); if (oldevents != s->async->events) |