staging: comedi: usbduxfast: use comedi_buf_write_samples()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 22 Oct 2014 22:36:45 +0000 (15:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2014 08:03:12 +0000 (16:03 +0800)
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/usbduxfast.c

index 95c2ec7ed22a1c0b53072bb24b126d75e493b965..70ec2f552dfc97e1c7811c5d425ee679cab899b2 100644 (file)
@@ -249,19 +249,17 @@ static void usbduxfast_ai_handle_urb(struct comedi_device *dev,
                devpriv->ignore--;
        } else {
                unsigned int nbytes = urb->actual_length;
+               unsigned int nsamples = nbytes / bytes_per_sample(s);
 
                if (cmd->stop_src == TRIG_COUNT) {
-                       unsigned int nsamples = nbytes / bytes_per_sample(s);
-
                        if (devpriv->ai_sample_count < nsamples) {
                                nsamples = devpriv->ai_sample_count;
                                async->events |= COMEDI_CB_EOA;
                        }
                        devpriv->ai_sample_count -= nsamples;
-                       nbytes = nsamples * bytes_per_sample(s);
                }
 
-               cfc_write_array_to_buffer(s, urb->transfer_buffer, nbytes);
+               comedi_buf_write_samples(s, urb->transfer_buffer, nsamples);
        }
 
        /* if command is still running, resubmit urb for BULK transfer */