Commit 2d7840c7 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: quatech_daqp_cs: 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 0be887b9
...@@ -65,8 +65,6 @@ struct daqp_private { ...@@ -65,8 +65,6 @@ struct daqp_private {
enum { semaphore, buffer } interrupt_mode; enum { semaphore, buffer } interrupt_mode;
struct completion eos; struct completion eos;
int count;
}; };
/* The DAQP communicates with the system through a 16 byte I/O window. */ /* The DAQP communicates with the system through a 16 byte I/O window. */
...@@ -194,6 +192,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) ...@@ -194,6 +192,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
struct comedi_device *dev = dev_id; struct comedi_device *dev = dev_id;
struct daqp_private *devpriv = dev->private; struct daqp_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev; struct comedi_subdevice *s = dev->read_subdev;
struct comedi_cmd *cmd = &s->async->cmd;
int loop_limit = 10000; int loop_limit = 10000;
int status; int status;
...@@ -227,12 +226,10 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) ...@@ -227,12 +226,10 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
* and stop conversion if zero * and stop conversion if zero
*/ */
if (devpriv->count > 0) { if (cmd->stop_src == TRIG_COUNT &&
devpriv->count--; s->async->scans_done >= cmd->stop_arg) {
if (devpriv->count == 0) { s->async->events |= COMEDI_CB_EOA;
s->async->events |= COMEDI_CB_EOA; break;
break;
}
} }
if ((loop_limit--) <= 0) if ((loop_limit--) <= 0)
...@@ -573,12 +570,16 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -573,12 +570,16 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/ */
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src == TRIG_COUNT) {
devpriv->count = cmd->stop_arg * cmd->scan_end_arg; unsigned long long nsamples;
threshold = 2 * devpriv->count; unsigned long long nbytes;
while (threshold > DAQP_FIFO_SIZE * 3 / 4)
threshold /= 2; nsamples = (unsigned long long)cmd->stop_arg *
cmd->scan_end_arg;
nbytes = nsamples * comedi_bytes_per_sample(s);
while (nbytes > DAQP_FIFO_SIZE * 3 / 4)
nbytes /= 2;
threshold = nbytes;
} else { } else {
devpriv->count = -1;
threshold = DAQP_FIFO_SIZE / 2; threshold = DAQP_FIFO_SIZE / 2;
} }
......
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