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

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