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

staging: comedi: dt282x: use cfc_handle_events()

Use the comedi_fc helper function to automatically call the subdevice
(*cancel) function when needed and call comedi_event().

This also fixes two bugs.
  1) the analog input command is canceled due to a buffer overflow
     without sending an event (@@ -341,7 +340,7 @@).
  2) an analog output error causes the command to cancel but the event
     is reported to the analog input subdevice (@@ -449,15 +447,13 @@).

In the Kconfig, COMEDI_DT282X already selects COMEDI_FC.
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 c9695093
...@@ -306,7 +306,6 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev) ...@@ -306,7 +306,6 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize); size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
if (size == 0) { if (size == 0) {
dev_err(dev->class_dev, "AO underrun\n"); dev_err(dev->class_dev, "AO underrun\n");
dt282x_ao_cancel(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
return; return;
} }
...@@ -341,7 +340,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) ...@@ -341,7 +340,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
dt282x_munge(dev, ptr, size); dt282x_munge(dev, ptr, size);
ret = cfc_write_array_to_buffer(s, ptr, size); ret = cfc_write_array_to_buffer(s, ptr, size);
if (ret != size) { if (ret != size) {
dt282x_ai_cancel(dev, s); s->async->events |= COMEDI_CB_OVERFLOW;
return; return;
} }
devpriv->nread -= size / 2; devpriv->nread -= size / 2;
...@@ -351,7 +350,6 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) ...@@ -351,7 +350,6 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
devpriv->nread = 0; devpriv->nread = 0;
} }
if (!devpriv->nread) { if (!devpriv->nread) {
dt282x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
return; return;
} }
...@@ -449,15 +447,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) ...@@ -449,15 +447,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
if (adcsr & DT2821_ADERR) { if (adcsr & DT2821_ADERR) {
if (devpriv->nread != 0) { if (devpriv->nread != 0) {
comedi_error(dev, "A/D error"); comedi_error(dev, "A/D error");
dt282x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_ERROR; s->async->events |= COMEDI_CB_ERROR;
} }
handled = 1; handled = 1;
} }
if (dacsr & DT2821_DAERR) { if (dacsr & DT2821_DAERR) {
comedi_error(dev, "D/A error"); comedi_error(dev, "D/A error");
dt282x_ao_cancel(dev, s_ao); s_ao->async->events |= COMEDI_CB_ERROR;
s->async->events |= COMEDI_CB_ERROR;
handled = 1; handled = 1;
} }
#if 0 #if 0
...@@ -486,7 +482,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) ...@@ -486,7 +482,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
handled = 1; handled = 1;
} }
#endif #endif
comedi_event(dev, s); cfc_handle_events(dev, s);
cfc_handle_events(dev, s_ao);
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
......
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