diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-11-05 10:21:09 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-05 14:59:48 -0800 |
commit | 5e62863aea463c9bf24538315327d0922be35d64 (patch) | |
tree | 390dcf1b7f0a85f6a86c840519e5a0cf236ba398 | |
parent | 324e213a06eb527cfba7d1efe5118cbff02afd7e (diff) |
staging: comedi: das800: use comedi_async 'scans_done' to detect EOA
Remove the private data member 'count' and use the comedi_async 'scans_done'
member to detect the end-of-acquisition.
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/das800.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 55bc494838b5..e5bdc2423445 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -219,7 +219,6 @@ static const struct das800_board das800_boards[] = { }; struct das800_private { - unsigned int count; /* number of data points left to be taken */ unsigned int divisor1; /* counter 1 value for timed conversions */ unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int do_bits; /* digital output bits */ @@ -286,9 +285,6 @@ static void das800_set_frequency(struct comedi_device *dev) static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct das800_private *devpriv = dev->private; - - devpriv->count = 0; das800_disable(dev); return 0; } @@ -399,7 +395,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { const struct das800_board *thisboard = dev->board_ptr; - struct das800_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int gain = CR_RANGE(cmd->chanlist[0]); @@ -422,11 +417,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, gain &= 0xf; outb(gain, dev->iobase + DAS800_GAIN); - if (cmd->stop_src == TRIG_COUNT) - devpriv->count = cmd->stop_arg * cmd->chanlist_len; - else /* TRIG_NONE */ - devpriv->count = 0; - /* enable auto channel scan, send interrupts on end of conversion * and set clock source to internal or external */ @@ -509,11 +499,13 @@ static irqreturn_t das800_interrupt(int irq, void *d) if (s->maxdata == 0x0fff) val >>= 4; /* 12-bit sample */ - /* if there are more data points to collect */ - if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { - val &= s->maxdata; - comedi_buf_write_samples(s, &val, 1); - devpriv->count--; + val &= s->maxdata; + comedi_buf_write_samples(s, &val, 1); + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) { + async->events |= COMEDI_CB_EOA; + break; } } @@ -524,9 +516,11 @@ static irqreturn_t das800_interrupt(int irq, void *d) return IRQ_HANDLED; } - if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { - /* Re-enable card's interrupt. - * We already have spinlock, so indirect addressing is safe */ + if (!(async->events & COMEDI_CB_CANCEL_MASK)) { + /* + * Re-enable card's interrupt. + * We already have spinlock, so indirect addressing is safe + */ das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits, CONTROL1); spin_unlock_irqrestore(&dev->spinlock, irq_flags); @@ -534,7 +528,6 @@ static irqreturn_t das800_interrupt(int irq, void *d) /* otherwise, stop taking data */ spin_unlock_irqrestore(&dev->spinlock, irq_flags); das800_disable(dev); - async->events |= COMEDI_CB_EOA; } comedi_handle_events(dev, s); return IRQ_HANDLED; |