From 39064f23284c68d3ce98e7f7b673a0ffa78c17ce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 18 Sep 2014 11:35:42 -0700 Subject: 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: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 8ed1506..b8fded3 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1089,8 +1089,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, ret = comedi_buf_get(s, &data); if (ret == 0) { s->async->events |= COMEDI_CB_OVERFLOW; - pci230_ao_stop(dev, s); - dev_err(dev->class_dev, "AO buffer underrun\n"); return; } pci230_ao_write_nofifo(dev, data, chan); @@ -1102,7 +1100,6 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, if (devpriv->ao_scan_count == 0) { /* End of acquisition. */ async->events |= COMEDI_CB_EOA; - pci230_ao_stop(dev, s); } } } @@ -1204,13 +1201,10 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev, events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } } - if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) { - /* Stopping AO due to completion or error. */ - pci230_ao_stop(dev, s); + if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) running = false; - } else { + else running = true; - } async->events |= events; return running; } @@ -1235,7 +1229,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev, /* Not using DAC FIFO. */ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); pci230_handle_ao_nofifo(dev, s); - comedi_event(dev, s); + comedi_handle_events(dev, s); } else { /* Using DAC FIFO. */ /* Read DACSWTRIG register to trigger conversion. */ @@ -1265,7 +1259,7 @@ static void pci230_ao_start(struct comedi_device *dev, /* Preload FIFO data. */ run = pci230_handle_ao_fifo(dev, s); - comedi_event(dev, s); + comedi_handle_events(dev, s); if (!run) { /* Stopped. */ return; @@ -2134,11 +2128,8 @@ static void pci230_handle_ai(struct comedi_device *dev, events |= COMEDI_CB_BLOCK; } async->events |= events; - if (async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | - COMEDI_CB_OVERFLOW)) { - /* disable hardware conversions */ - pci230_ai_stop(dev, s); - } else { + if (!(async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | + COMEDI_CB_OVERFLOW))) { /* update FIFO interrupt trigger level */ pci230_ai_update_fifo_trigger_level(dev, s); } @@ -2355,7 +2346,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) unsigned char status_int, valid_status_int, temp_ier; struct comedi_device *dev = (struct comedi_device *)d; 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; /* Read interrupt status/enable register. */ @@ -2385,23 +2377,14 @@ static irqreturn_t pci230_interrupt(int irq, void *d) * two. */ - if (valid_status_int & PCI230_INT_ZCLK_CT1) { - s = dev->write_subdev; - pci230_handle_ao_nofifo(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230_INT_ZCLK_CT1) + pci230_handle_ao_nofifo(dev, s_ao); - if (valid_status_int & PCI230P2_INT_DAC) { - s = dev->write_subdev; - pci230_handle_ao_fifo(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230P2_INT_DAC) + pci230_handle_ao_fifo(dev, s_ao); - if (valid_status_int & PCI230_INT_ADC) { - s = dev->read_subdev; - pci230_handle_ai(dev, s); - comedi_event(dev, s); - } + if (valid_status_int & PCI230_INT_ADC) + pci230_handle_ai(dev, s_ai); /* Reenable interrupts. */ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); @@ -2410,6 +2393,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d) devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); + comedi_handle_events(dev, s_ao); + comedi_handle_events(dev, s_ai); + return IRQ_HANDLED; } -- cgit v0.10.2