[PATCH 24/67 v2] staging: comedi: pcl816: clarify 'irq_was_now_closed' flag in private data

H Hartley Sweeten hsweeten at visionengravers.com
Tue Mar 4 18:29:44 UTC 2014


This flag in the private data is set when an async command is canceled with
the ai (*cancel) operation. Rename the flag to 'ai_cmd_canceled' to clarify
its use.

Move the check for the flag in the interrupt handler. If the async command
was canceled there is no reason to handle the interrupt. Just clear interrupt
and return.

Also, make sure to clear the interrupt when the device is not attached.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/pcl816.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index d6dae54..e77bf9f 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -120,7 +120,7 @@ struct pcl816_private {
 	unsigned int divisor1;
 	unsigned int divisor2;
 	unsigned int ai_cmd_running:1;
-	unsigned int irq_was_now_closed:1;
+	unsigned int ai_cmd_canceled:1;
 };
 
 static int check_channel_list(struct comedi_device *dev,
@@ -346,6 +346,13 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
 
 	if (!dev->attached) {
 		comedi_error(dev, "premature interrupt");
+		outb(0, dev->iobase + PCL816_CLRINT);
+		return IRQ_HANDLED;
+	}
+
+	if (devpriv->ai_cmd_canceled) {
+		devpriv->ai_cmd_canceled = 0;
+		outb(0, dev->iobase + PCL816_CLRINT);
 		return IRQ_HANDLED;
 	}
 
@@ -357,11 +364,6 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
 
 	outb(0, dev->iobase + PCL816_CLRINT);	/* clear INT request */
 	if (!devpriv->ai_cmd_running || !devpriv->int816_mode) {
-		if (devpriv->irq_was_now_closed) {
-			devpriv->irq_was_now_closed = 0;
-			/*  comedi_error(dev,"last IRQ.."); */
-			return IRQ_HANDLED;
-		}
 		comedi_error(dev, "bad IRQ!");
 		return IRQ_NONE;
 	}
@@ -469,7 +471,7 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	s->async->cur_chan = 0;
 	devpriv->ai_cmd_running = 1;
 	devpriv->ai_poll_ptr = 0;
-	devpriv->irq_was_now_closed = 0;
+	devpriv->ai_cmd_canceled = 0;
 
 	if (devpriv->dma)
 		pcl816_ai_setup_dma(dev, s);
@@ -576,7 +578,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev,
 		/* Stop A/D */
 		outb(0, dev->iobase + PCL816_CONTROL);
 		devpriv->ai_cmd_running = 0;
-		devpriv->irq_was_now_closed = 1;
+		devpriv->ai_cmd_canceled = 1;
 		devpriv->int816_mode = 0;
 		break;
 	}
-- 
1.8.5.2



More information about the devel mailing list