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

staging: comedi: usbdux: use comedi_async 'scans_done' to detect AI EOA

Remove the private data member 'ai_sample_count' and use the comedi_async
'scans_done' member to detect the analog input end-of-acquisition.

Move the EOA check so it happens after adding the samples from the current
urb to the async buffer. This prevents the unnecessary resubmit of the urb
when the EOA occurs.
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 7c5fc7dd
...@@ -202,8 +202,6 @@ struct usbdux_private { ...@@ -202,8 +202,6 @@ struct usbdux_private {
unsigned int ao_cmd_running:1; unsigned int ao_cmd_running:1;
unsigned int pwm_cmd_running:1; unsigned int pwm_cmd_running:1;
/* number of samples to acquire */
int ai_sample_count;
/* time between samples in units of the timer */ /* time between samples in units of the timer */
unsigned int ai_timer; unsigned int ai_timer;
unsigned int ao_timer; unsigned int ao_timer;
...@@ -263,14 +261,6 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev, ...@@ -263,14 +261,6 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev,
if (devpriv->ai_counter == 0) { if (devpriv->ai_counter == 0) {
devpriv->ai_counter = devpriv->ai_timer; devpriv->ai_counter = devpriv->ai_timer;
if (cmd->stop_src == TRIG_COUNT) {
devpriv->ai_sample_count--;
if (devpriv->ai_sample_count < 0) {
async->events |= COMEDI_CB_EOA;
return;
}
}
/* get the data from the USB bus and hand it over to comedi */ /* get the data from the USB bus and hand it over to comedi */
for (i = 0; i < cmd->chanlist_len; i++) { for (i = 0; i < cmd->chanlist_len; i++) {
unsigned int range = CR_RANGE(cmd->chanlist[i]); unsigned int range = CR_RANGE(cmd->chanlist[i]);
...@@ -284,6 +274,10 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev, ...@@ -284,6 +274,10 @@ static void usbduxsub_ai_handle_urb(struct comedi_device *dev,
if (!comedi_buf_write_samples(s, &val, 1)) if (!comedi_buf_write_samples(s, &val, 1))
return; return;
} }
if (cmd->stop_src == TRIG_COUNT &&
async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
} }
/* if command is still running, resubmit urb */ /* if command is still running, resubmit urb */
...@@ -732,14 +726,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -732,14 +726,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->ai_counter = devpriv->ai_timer; devpriv->ai_counter = devpriv->ai_timer;
if (cmd->stop_src == TRIG_COUNT) {
/* data arrives as one packet */
devpriv->ai_sample_count = cmd->stop_arg;
} else {
/* continous acquisition */
devpriv->ai_sample_count = 0;
}
if (cmd->start_src == TRIG_NOW) { if (cmd->start_src == TRIG_NOW) {
/* enable this acquisition operation */ /* enable this acquisition operation */
devpriv->ai_cmd_running = 1; devpriv->ai_cmd_running = 1;
......
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