Commit 5e62863a authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 324e213a
...@@ -219,7 +219,6 @@ static const struct das800_board das800_boards[] = { ...@@ -219,7 +219,6 @@ static const struct das800_board das800_boards[] = {
}; };
struct das800_private { 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 divisor1; /* counter 1 value for timed conversions */
unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int divisor2; /* counter 2 value for timed conversions */
unsigned int do_bits; /* digital output bits */ unsigned int do_bits; /* digital output bits */
...@@ -286,9 +285,6 @@ static void das800_set_frequency(struct comedi_device *dev) ...@@ -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) static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
struct das800_private *devpriv = dev->private;
devpriv->count = 0;
das800_disable(dev); das800_disable(dev);
return 0; return 0;
} }
...@@ -399,7 +395,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, ...@@ -399,7 +395,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
const struct das800_board *thisboard = dev->board_ptr; const struct das800_board *thisboard = dev->board_ptr;
struct das800_private *devpriv = dev->private;
struct comedi_async *async = s->async; struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd; struct comedi_cmd *cmd = &async->cmd;
unsigned int gain = CR_RANGE(cmd->chanlist[0]); unsigned int gain = CR_RANGE(cmd->chanlist[0]);
...@@ -422,11 +417,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev, ...@@ -422,11 +417,6 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
gain &= 0xf; gain &= 0xf;
outb(gain, dev->iobase + DAS800_GAIN); 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 /* enable auto channel scan, send interrupts on end of conversion
* and set clock source to internal or external * and set clock source to internal or external
*/ */
...@@ -509,11 +499,13 @@ static irqreturn_t das800_interrupt(int irq, void *d) ...@@ -509,11 +499,13 @@ static irqreturn_t das800_interrupt(int irq, void *d)
if (s->maxdata == 0x0fff) if (s->maxdata == 0x0fff)
val >>= 4; /* 12-bit sample */ val >>= 4; /* 12-bit sample */
/* if there are more data points to collect */ val &= s->maxdata;
if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { comedi_buf_write_samples(s, &val, 1);
val &= s->maxdata;
comedi_buf_write_samples(s, &val, 1); if (cmd->stop_src == TRIG_COUNT &&
devpriv->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) ...@@ -524,9 +516,11 @@ static irqreturn_t das800_interrupt(int irq, void *d)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
/* Re-enable card's interrupt. /*
* We already have spinlock, so indirect addressing is safe */ * Re-enable card's interrupt.
* We already have spinlock, so indirect addressing is safe
*/
das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits, das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits,
CONTROL1); CONTROL1);
spin_unlock_irqrestore(&dev->spinlock, irq_flags); spin_unlock_irqrestore(&dev->spinlock, irq_flags);
...@@ -534,7 +528,6 @@ static irqreturn_t das800_interrupt(int irq, void *d) ...@@ -534,7 +528,6 @@ static irqreturn_t das800_interrupt(int irq, void *d)
/* otherwise, stop taking data */ /* otherwise, stop taking data */
spin_unlock_irqrestore(&dev->spinlock, irq_flags); spin_unlock_irqrestore(&dev->spinlock, irq_flags);
das800_disable(dev); das800_disable(dev);
async->events |= COMEDI_CB_EOA;
} }
comedi_handle_events(dev, s); comedi_handle_events(dev, s);
return IRQ_HANDLED; return IRQ_HANDLED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment