staging: comedi: cb_pcidas64: use comedi_buf_write_samples()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 22 Oct 2014 22:36:35 +0000 (15:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2014 08:03:11 +0000 (16:03 +0800)
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi samples writes by 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/cb_pcidas64.c

index 06e846f389925f97fd3e1ed03df241f184856c2b..9196680581b8631b81bb2c35a2b61666d24b6ec2 100644 (file)
@@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
                }
 
                for (i = 0; i < num_samples; i++) {
-                       cfc_write_to_buffer(s,
-                                           readw(devpriv->main_iobase +
-                                                 ADC_FIFO_REG));
+                       unsigned short val;
+
+                       val = readw(devpriv->main_iobase + ADC_FIFO_REG);
+                       comedi_buf_write_samples(s, &val, 1);
                }
 
        } while (read_segment != write_segment);
@@ -2722,11 +2723,15 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev)
 
        }
        for (i = 0; read_code != write_code && i < max_transfer;) {
+               unsigned short val;
+
                fifo_data = readl(dev->mmio + ADC_FIFO_REG);
-               cfc_write_to_buffer(s, fifo_data & 0xffff);
+               val = fifo_data & 0xffff;
+               comedi_buf_write_samples(s, &val, 1);
                i++;
                if (i < max_transfer) {
-                       cfc_write_to_buffer(s, (fifo_data >> 16) & 0xffff);
+                       val = (fifo_data >> 16) & 0xffff;
+                       comedi_buf_write_samples(s, &val, 1);
                        i++;
                }
                read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) &
@@ -2778,10 +2783,9 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
                                num_samples = devpriv->ai_count;
                        devpriv->ai_count -= num_samples;
                }
-               cfc_write_array_to_buffer(dev->read_subdev,
-                                         devpriv->ai_buffer[devpriv->
-                                                            ai_dma_index],
-                                         num_samples * sizeof(uint16_t));
+               comedi_buf_write_samples(dev->read_subdev,
+                               devpriv->ai_buffer[devpriv->ai_dma_index],
+                               num_samples);
                devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) %
                                        ai_dma_ring_count(thisboard);
        }