Commit 7ba38a01 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: cb_pcidas64: use comedi_buf_write_samples()

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 28e8c898
...@@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) ...@@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
} }
for (i = 0; i < num_samples; i++) { for (i = 0; i < num_samples; i++) {
cfc_write_to_buffer(s, unsigned short val;
readw(devpriv->main_iobase +
ADC_FIFO_REG)); val = readw(devpriv->main_iobase + ADC_FIFO_REG);
comedi_buf_write_samples(s, &val, 1);
} }
} while (read_segment != write_segment); } while (read_segment != write_segment);
...@@ -2722,11 +2723,15 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) ...@@ -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;) { for (i = 0; read_code != write_code && i < max_transfer;) {
unsigned short val;
fifo_data = readl(dev->mmio + ADC_FIFO_REG); 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++; i++;
if (i < max_transfer) { 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++; i++;
} }
read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) & 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) ...@@ -2778,10 +2783,9 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
num_samples = devpriv->ai_count; num_samples = devpriv->ai_count;
devpriv->ai_count -= num_samples; devpriv->ai_count -= num_samples;
} }
cfc_write_array_to_buffer(dev->read_subdev, comedi_buf_write_samples(dev->read_subdev,
devpriv->ai_buffer[devpriv-> devpriv->ai_buffer[devpriv->ai_dma_index],
ai_dma_index], num_samples);
num_samples * sizeof(uint16_t));
devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) % devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) %
ai_dma_ring_count(thisboard); ai_dma_ring_count(thisboard);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment