From: H Hartley Sweeten Date: Wed, 22 Oct 2014 22:36:45 +0000 (-0700) Subject: staging: comedi: usbduxfast: use comedi_buf_write_samples() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=f81ac41b89798a53f03e2204153598b229958660;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: usbduxfast: use comedi_buf_write_samples() 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 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 95c2ec7ed22a..70ec2f552dfc 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -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 */