[PATCH 43/67 v2] staging: comedi: pcl812: introduce pcl812_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.

Remove a redundant call in pcl812_ai_cancel().

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

diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index cf183c8..b41dbbc 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -637,6 +637,12 @@ static void pcl812_ai_setup_next_dma(struct comedi_device *dev,
 	enable_dma(devpriv->dma);
 }
 
+static void pcl812_ai_clear_eoc(struct comedi_device *dev)
+{
+	/* writing any value clears the interrupt request */
+	outb(0, dev->iobase + PCL812_CLRINT);
+}
+
 static unsigned int pcl812_ai_get_sample(struct comedi_device *dev,
 					 struct comedi_subdevice *s)
 {
@@ -889,7 +895,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d)
 	struct pcl812_private *devpriv = dev->private;
 
 	if (!dev->attached) {
-		outb(0, dev->iobase + PCL812_CLRINT);
+		pcl812_ai_clear_eoc(dev);
 		return IRQ_HANDLED;
 	}
 
@@ -898,7 +904,7 @@ static irqreturn_t pcl812_interrupt(int irq, void *d)
 	else
 		pcl812_handle_eoc(dev, s);
 
-	outb(0, dev->iobase + PCL812_CLRINT);
+	pcl812_ai_clear_eoc(dev);
 
 	comedi_event(dev, s);
 	return IRQ_HANDLED;
@@ -997,11 +1003,11 @@ static int pcl812_ai_cancel(struct comedi_device *dev,
 
 	if (devpriv->ai_dma)
 		disable_dma(devpriv->dma);
-	outb(0, dev->iobase + PCL812_CLRINT);	/* clear INT request */
-							/* Stop A/D */
+
+	/* Stop A/D */
 	outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
 	pcl812_start_pacer(dev, false);
-	outb(0, dev->iobase + PCL812_CLRINT);	/* clear INT request */
+	pcl812_ai_clear_eoc(dev);
 	return 0;
 }
 
@@ -1021,8 +1027,7 @@ static int pcl812_ai_insn_read(struct comedi_device *dev,
 	setup_range_channel(dev, s, insn->chanspec, 1);
 
 	for (i = 0; i < insn->n; i++) {
-		/* clear INT request */
-		outb(0, dev->iobase + PCL812_CLRINT);
+		pcl812_ai_clear_eoc(dev);
 		/* start conversion */
 		outb(255, dev->iobase + PCL812_SOFTTRIG);
 
@@ -1032,9 +1037,8 @@ static int pcl812_ai_insn_read(struct comedi_device *dev,
 
 		data[i] = pcl812_ai_get_sample(dev, s);
 	}
-	/* clear INT request */
-	outb(0, dev->iobase + PCL812_CLRINT);
 	outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
+	pcl812_ai_clear_eoc(dev);
 
 	return ret ? ret : insn->n;
 }
@@ -1126,7 +1130,7 @@ static void pcl812_reset(struct comedi_device *dev)
 		outb(0, dev->iobase + PCL812_DO_MSB_REG);
 		outb(0, dev->iobase + PCL812_DO_LSB_REG);
 		outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
-		outb(0, dev->iobase + PCL812_CLRINT);
+		pcl812_ai_clear_eoc(dev);
 		break;
 	case boardPCL813B:
 	case boardPCL813:
-- 
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