staging: comedi: pcl816: clarify 'irq_was_now_closed' flag in private data
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Mar 2014 18:29:44 +0000 (11:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2014 01:06:13 +0000 (17:06 -0800)
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@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcl816.c

index d6dae54660236f79c03018e73dbdecc8290cfac6..e77bf9fb2a9a2ca411e8abd7b99575c17ac698dc 100644 (file)
@@ -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;
        }