[PATCH 43/66] staging: comedi: pcl816: introduce pcl816_ai_clear_eoc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce a helper function to clear the end-of-conversion flag.

This flag is set when an analog input conversion is finished and the
hardware generates an interrupt request. Writing any value to the
register resets the flag and re-enables the interrupt.

Move the call in pcl816_ai_cancel() so that the flag is reset after
stopping the A/D.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/pcl816.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 11a6dbe..7b8ad6d 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -208,6 +208,12 @@ static void pcl816_ai_setup_next_dma(struct comedi_device *dev,
 	devpriv->dma_runs_to_end--;
 }
 
+static void pcl816_ai_clear_eoc(struct comedi_device *dev)
+{
+	/* writing any value clears the interrupt request */
+	outb(0, dev->iobase + PCL816_CLRINT);
+}
+
 static unsigned int pcl816_ai_get_sample(struct comedi_device *dev,
 					 struct comedi_subdevice *s)
 {
@@ -315,13 +321,13 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
 	struct pcl816_private *devpriv = dev->private;
 
 	if (!dev->attached || !devpriv->ai_cmd_running) {
-		outb(0, dev->iobase + PCL816_CLRINT);
+		pcl816_ai_clear_eoc(dev);
 		return IRQ_HANDLED;
 	}
 
 	if (devpriv->ai_cmd_canceled) {
 		devpriv->ai_cmd_canceled = 0;
-		outb(0, dev->iobase + PCL816_CLRINT);
+		pcl816_ai_clear_eoc(dev);
 		return IRQ_HANDLED;
 	}
 
@@ -330,7 +336,7 @@ static irqreturn_t pcl816_interrupt(int irq, void *d)
 	else
 		pcl816_handle_eoc(dev, s);
 
-	outb(0, dev->iobase + PCL816_CLRINT);
+	pcl816_ai_clear_eoc(dev);
 
 	comedi_event(dev, s);
 	return IRQ_HANDLED;
@@ -534,11 +540,10 @@ static int pcl816_ai_cancel(struct comedi_device *dev,
 	outb(0, dev->iobase + PCL816_AD_LO);
 	pcl816_ai_get_sample(dev, s);
 
-	/* clear INT request */
-	outb(0, dev->iobase + PCL816_CLRINT);
-
 	/* Stop A/D */
 	outb(0, dev->iobase + PCL816_CONTROL);
+	pcl816_ai_clear_eoc(dev);
+
 	devpriv->ai_cmd_running = 0;
 	devpriv->ai_cmd_canceled = 1;
 
@@ -642,8 +647,7 @@ static int pcl816_ai_insn_read(struct comedi_device *dev,
 	outb(range, dev->iobase + PCL816_RANGE);
 
 	for (i = 0; i < insn->n; i++) {
-		/* clear INT (conversion end) flag */
-		outb(0, dev->iobase + PCL816_CLRINT);
+		pcl816_ai_clear_eoc(dev);
 		/* start conversion */
 		outb(0, dev->iobase + PCL816_AD_LO);
 
@@ -653,8 +657,7 @@ static int pcl816_ai_insn_read(struct comedi_device *dev,
 
 		data[i] = pcl816_ai_get_sample(dev, s);
 	}
-	/* clear INT (conversion end) flag */
-	outb(0, dev->iobase + PCL816_CLRINT);
+	pcl816_ai_clear_eoc(dev);
 
 	return ret ? ret : insn->n;
 }
@@ -691,7 +694,7 @@ static void pcl816_reset(struct comedi_device *dev)
 
 	outb(0, dev->iobase + PCL816_CONTROL);
 	outb(0, dev->iobase + PCL816_MUX);
-	outb(0, dev->iobase + PCL816_CLRINT);
+	pcl816_ai_clear_eoc(dev);
 
 	/* Stop pacer */
 	i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);
-- 
1.8.5.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux