staging: comedi: dt282x: use comedi_buf_write_samples()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 22 Oct 2014 22:36:42 +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/dt282x.c

index 88b56104d4e776c74719828c3c65a4d251eb729a..1d9fa371d03c94c5e1be9a74b792d9f1b5f262d1 100644 (file)
@@ -491,6 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
        int cur_dma = devpriv->current_dma_index;
        void *ptr = devpriv->dma[cur_dma].buf;
        int size = devpriv->dma[cur_dma].size;
+       unsigned int nsamples = size / bytes_per_sample(s);
        int ret;
 
        outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE,
@@ -501,13 +502,11 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
        devpriv->current_dma_index = 1 - cur_dma;
 
        dt282x_munge(dev, s, ptr, size);
-       ret = cfc_write_array_to_buffer(s, ptr, size);
-       if (ret != size) {
-               s->async->events |= COMEDI_CB_OVERFLOW;
+       ret = comedi_buf_write_samples(s, ptr, nsamples);
+       if (ret != size)
                return;
-       }
 
-       devpriv->nread -= size / 2;
+       devpriv->nread -= nsamples;
        if (devpriv->nread < 0) {
                dev_info(dev->class_dev, "nread off by one\n");
                devpriv->nread = 0;
@@ -566,7 +565,6 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
        }
 #if 0
        if (adcsr & DT2821_ADCSR_ADDONE) {
-               int ret;
                unsigned short data;
 
                data = inw(dev->iobase + DT2821_ADDAT_REG);
@@ -574,10 +572,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
                if (devpriv->ad_2scomp)
                        data = comedi_offset_munge(s, data);
 
-               ret = comedi_buf_put(s, data);
-
-               if (ret == 0)
-                       s->async->events |= COMEDI_CB_OVERFLOW;
+               comedi_buf_write_samples(s, &data, 1);
 
                devpriv->nread--;
                if (!devpriv->nread) {