From: H Hartley Sweeten Date: Tue, 4 Mar 2014 18:29:43 +0000 (-0700) Subject: staging: comedi: pcl818: reduce indent level in pcl818_ai_cancel() X-Git-Tag: firefly_0821_release~176^2~4193^2~660 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2850b1c74ef065368827776a612cb0d873a39d8e;p=firefly-linux-kernel-4.4.55.git staging: comedi: pcl818: reduce indent level in pcl818_ai_cancel() 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 745beddecdd4..c820df2aac45 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; }