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

staging: comedi: amplc_pci230: use comedi_handle_events()

Use comedi_handle_events() to automatically (*cancel) the async command
for an end-of-acquisition or if an error/overflow occurs.
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 a708e091
...@@ -1089,8 +1089,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ...@@ -1089,8 +1089,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev,
ret = comedi_buf_get(s, &data); ret = comedi_buf_get(s, &data);
if (ret == 0) { if (ret == 0) {
s->async->events |= COMEDI_CB_OVERFLOW; s->async->events |= COMEDI_CB_OVERFLOW;
pci230_ao_stop(dev, s);
dev_err(dev->class_dev, "AO buffer underrun\n");
return; return;
} }
pci230_ao_write_nofifo(dev, data, chan); pci230_ao_write_nofifo(dev, data, chan);
...@@ -1102,7 +1100,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ...@@ -1102,7 +1100,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev,
if (devpriv->ao_scan_count == 0) { if (devpriv->ao_scan_count == 0) {
/* End of acquisition. */ /* End of acquisition. */
async->events |= COMEDI_CB_EOA; async->events |= COMEDI_CB_EOA;
pci230_ao_stop(dev, s);
} }
} }
} }
...@@ -1204,13 +1201,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, ...@@ -1204,13 +1201,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
} }
} }
if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) { if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
/* Stopping AO due to completion or error. */
pci230_ao_stop(dev, s);
running = false; running = false;
} else { else
running = true; running = true;
}
async->events |= events; async->events |= events;
return running; return running;
} }
...@@ -1235,7 +1229,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, ...@@ -1235,7 +1229,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
/* Not using DAC FIFO. */ /* Not using DAC FIFO. */
spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
pci230_handle_ao_nofifo(dev, s); pci230_handle_ao_nofifo(dev, s);
comedi_event(dev, s); comedi_handle_events(dev, s);
} else { } else {
/* Using DAC FIFO. */ /* Using DAC FIFO. */
/* Read DACSWTRIG register to trigger conversion. */ /* Read DACSWTRIG register to trigger conversion. */
...@@ -1265,7 +1259,7 @@ static void pci230_ao_start(struct comedi_device *dev, ...@@ -1265,7 +1259,7 @@ static void pci230_ao_start(struct comedi_device *dev,
/* Preload FIFO data. */ /* Preload FIFO data. */
run = pci230_handle_ao_fifo(dev, s); run = pci230_handle_ao_fifo(dev, s);
comedi_event(dev, s); comedi_handle_events(dev, s);
if (!run) { if (!run) {
/* Stopped. */ /* Stopped. */
return; return;
...@@ -2134,11 +2128,8 @@ static void pci230_handle_ai(struct comedi_device *dev, ...@@ -2134,11 +2128,8 @@ static void pci230_handle_ai(struct comedi_device *dev,
events |= COMEDI_CB_BLOCK; events |= COMEDI_CB_BLOCK;
} }
async->events |= events; async->events |= events;
if (async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | if (!(async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
COMEDI_CB_OVERFLOW)) { COMEDI_CB_OVERFLOW))) {
/* disable hardware conversions */
pci230_ai_stop(dev, s);
} else {
/* update FIFO interrupt trigger level */ /* update FIFO interrupt trigger level */
pci230_ai_update_fifo_trigger_level(dev, s); pci230_ai_update_fifo_trigger_level(dev, s);
} }
...@@ -2355,7 +2346,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) ...@@ -2355,7 +2346,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
unsigned char status_int, valid_status_int, temp_ier; unsigned char status_int, valid_status_int, temp_ier;
struct comedi_device *dev = (struct comedi_device *)d; struct comedi_device *dev = (struct comedi_device *)d;
struct pci230_private *devpriv = dev->private; struct pci230_private *devpriv = dev->private;
struct comedi_subdevice *s; struct comedi_subdevice *s_ao = dev->write_subdev;
struct comedi_subdevice *s_ai = dev->read_subdev;
unsigned long irqflags; unsigned long irqflags;
/* Read interrupt status/enable register. */ /* Read interrupt status/enable register. */
...@@ -2385,23 +2377,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d) ...@@ -2385,23 +2377,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
* two. * two.
*/ */
if (valid_status_int & PCI230_INT_ZCLK_CT1) { if (valid_status_int & PCI230_INT_ZCLK_CT1)
s = dev->write_subdev; pci230_handle_ao_nofifo(dev, s_ao);
pci230_handle_ao_nofifo(dev, s);
comedi_event(dev, s);
}
if (valid_status_int & PCI230P2_INT_DAC) { if (valid_status_int & PCI230P2_INT_DAC)
s = dev->write_subdev; pci230_handle_ao_fifo(dev, s_ao);
pci230_handle_ao_fifo(dev, s);
comedi_event(dev, s);
}
if (valid_status_int & PCI230_INT_ADC) { if (valid_status_int & PCI230_INT_ADC)
s = dev->read_subdev; pci230_handle_ai(dev, s_ai);
pci230_handle_ai(dev, s);
comedi_event(dev, s);
}
/* Reenable interrupts. */ /* Reenable interrupts. */
spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
...@@ -2410,6 +2393,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d) ...@@ -2410,6 +2393,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
devpriv->intr_running = false; devpriv->intr_running = false;
spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
comedi_handle_events(dev, s_ao);
comedi_handle_events(dev, s_ai);
return IRQ_HANDLED; return IRQ_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