If an async command is not running the (*cancel) function doesn't do
anything. Exit the function early if this is the case.

This allows reducing the indent level in the rest of the function.

Also, move the setting of the 'irq_was_now_closed' to the only place
wher it actually gets left set to 1 and remove the goto.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/pcl818.c | 69 +++++++++++++++++----------------
 1 file changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl818.c 
b/drivers/staging/comedi/drivers/pcl818.c
index c28671f..202ebea 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -1057,42 +1057,45 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
        struct pcl818_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       if (devpriv->ai_cmd_running) {
-               devpriv->irq_was_now_closed = 1;
-
-               switch (devpriv->ai_mode) {
-               case INT_TYPE_AI1_DMA:
-               case INT_TYPE_AI3_DMA:
-                       if (cmd->stop_src == TRIG_NONE ||
-                           (cmd->stop_src == TRIG_COUNT && 
devpriv->ai_act_scan > 0)) {
-                               /* wait for running dma transfer to end, do 
cleanup in interrupt */
-                               goto end;
-                       }
-                       disable_dma(devpriv->dma);
-               case INT_TYPE_AI1_INT:
-               case INT_TYPE_AI3_INT:
-               case INT_TYPE_AI1_FIFO:
-               case INT_TYPE_AI3_FIFO:
-                       outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, 
dev->iobase + PCL818_CONTROL);   /* Stop A/D */
-                       udelay(1);
-                       pcl818_start_pacer(dev, false);
-                       outb(0, dev->iobase + PCL818_AD_LO);
-                       pcl818_ai_get_sample(dev, s, NULL);
-                       outb(0, dev->iobase + PCL818_CLRINT);   /* clear INT 
request */
-                       outb(0, dev->iobase + PCL818_CONTROL);  /* Stop A/D */
-                       if (devpriv->usefifo) { /*  FIFO shutdown */
-                               outb(0, dev->iobase + PCL818_FI_INTCLR);
-                               outb(0, dev->iobase + PCL818_FI_FLUSH);
-                               outb(0, dev->iobase + PCL818_FI_ENABLE);
-                       }
-                       devpriv->ai_cmd_running = 0;
-                       devpriv->ai_mode = 0;
-                       devpriv->irq_was_now_closed = 0;
-                       break;
+       if (!devpriv->ai_cmd_running)
+               return 0;
+
+       switch (devpriv->ai_mode) {
+       case INT_TYPE_AI1_DMA:
+       case INT_TYPE_AI3_DMA:
+               if (cmd->stop_src == TRIG_NONE ||
+                   (cmd->stop_src == TRIG_COUNT && devpriv->ai_act_scan > 0)) {
+                       /*
+                        * Wait for running dma transfer to end,
+                        * do cleanup in interrupt.
+                        */
+                       devpriv->irq_was_now_closed = 1;
+                       return 0;
                }
+               disable_dma(devpriv->dma);
+       case INT_TYPE_AI1_INT:
+       case INT_TYPE_AI3_INT:
+       case INT_TYPE_AI1_FIFO:
+       case INT_TYPE_AI3_FIFO:
+               outb(inb(dev->iobase + PCL818_CONTROL) & 0x73,
+                    dev->iobase + PCL818_CONTROL);     /* Stop A/D */
+               udelay(1);
+               pcl818_start_pacer(dev, false);
+               outb(0, dev->iobase + PCL818_AD_LO);
+               pcl818_ai_get_sample(dev, s, NULL);
+               outb(0, dev->iobase + PCL818_CLRINT);   /* clear INT request */
+               outb(0, dev->iobase + PCL818_CONTROL);  /* Stop A/D */
+               if (devpriv->usefifo) { /*  FIFO shutdown */
+                       outb(0, dev->iobase + PCL818_FI_INTCLR);
+                       outb(0, dev->iobase + PCL818_FI_FLUSH);
+                       outb(0, dev->iobase + PCL818_FI_ENABLE);
+               }
+               devpriv->ai_cmd_running = 0;
+               devpriv->ai_mode = 0;
+               devpriv->irq_was_now_closed = 0;
+               break;
        }
 
-end:
        return 0;
 }
 
-- 
1.8.5.2

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

Reply via email to