From: H Hartley Sweeten Date: Wed, 5 Nov 2014 17:31:35 +0000 (-0700) Subject: staging: comedi: usbduxfast: use comedi_async 'scans_done' to detect AI EOA X-Git-Tag: firefly_0821_release~176^2~2665^2~365 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=979f99963cedb8a25f21ac9315082719d768379b;p=firefly-linux-kernel-4.4.55.git staging: comedi: usbduxfast: 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. Use the comedi_nsamples_left() helper to get the number of samples to actually add to the async buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 5de76aba8fd9..ddc4cb9d5ed4 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -161,7 +161,6 @@ struct usbduxfast_private { uint8_t *duxbuf; int8_t *inbuf; short int ai_cmd_running; /* asynchronous command is running */ - long int ai_sample_count; /* number of samples to acquire */ int ignore; /* counter which ignores the first buffers */ struct semaphore sem; @@ -251,15 +250,12 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev, unsigned int nsamples; nsamples = comedi_bytes_to_samples(s, urb->actual_length); - if (cmd->stop_src == TRIG_COUNT) { - if (devpriv->ai_sample_count < nsamples) { - nsamples = devpriv->ai_sample_count; - async->events |= COMEDI_CB_EOA; - } - devpriv->ai_sample_count -= nsamples; - } - + nsamples = comedi_nsamples_left(s, nsamples); comedi_buf_write_samples(s, urb->transfer_buffer, nsamples); + + if (cmd->stop_src == TRIG_COUNT && + async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; } /* if command is still running, resubmit urb for BULK transfer */ @@ -788,11 +784,6 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, return result; } - if (cmd->stop_src == TRIG_COUNT) - devpriv->ai_sample_count = cmd->stop_arg * cmd->scan_end_arg; - else /* TRIG_NONE */ - devpriv->ai_sample_count = 0; - if ((cmd->start_src == TRIG_NOW) || (cmd->start_src == TRIG_EXT)) { /* enable this acquisition operation */ devpriv->ai_cmd_running = 1;