[PATCH 16/18] staging: comedi: usbduxsigma: use comedi_async 'scans_done' to detect AI EOA
Ian Abbott
abbotti at mev.co.uk
Wed Nov 5 11:35:37 UTC 2014
On 04/11/14 16:50, H Hartley Sweeten wrote:
> 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: H Hartley Sweeten <hsweeten at visionengravers.com>
> Cc: Ian Abbott <abbotti at mev.co.uk>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> ---
> drivers/staging/comedi/drivers/usbduxsigma.c | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
> index 31b2806..dc19435 100644
> --- a/drivers/staging/comedi/drivers/usbduxsigma.c
> +++ b/drivers/staging/comedi/drivers/usbduxsigma.c
> @@ -164,8 +164,6 @@ struct usbduxsigma_private {
> unsigned ao_cmd_running:1;
> unsigned pwm_cmd_running:1;
>
> - /* number of samples to acquire */
> - int ai_sample_count;
> /* time between samples in units of the timer */
> unsigned int ai_timer;
> unsigned int ao_timer;
> @@ -226,14 +224,6 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev,
> if (devpriv->ai_counter == 0) {
> 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 state of the dio pins to allow external trigger */
> dio_state = be32_to_cpu(devpriv->in_buf[0]);
>
> @@ -247,6 +237,10 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev,
> if (!comedi_buf_write_samples(s, &val, 1))
> return;
> }
> +
> + if (cmd->stop_src == TRIG_COUNT &&
> + async->scans_done >= cmd->stop_arg)
> + async->events |= COMEDI_CB_EOA;
Again, you could return early here, but it doesn't really matter.
> }
>
> /* if command is still running, resubmit urb */
> @@ -578,14 +572,6 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
> if (devpriv->ai_timer < 1)
> err |= -EINVAL;
>
> - if (cmd->stop_src == TRIG_COUNT) {
> - /* data arrives as one packet */
> - devpriv->ai_sample_count = cmd->stop_arg;
> - } else {
> - /* continuous acquisition */
> - devpriv->ai_sample_count = 0;
> - }
> -
> if (err)
> return 4;
>
>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti at mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
More information about the devel
mailing list