Commit 28215c69 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_3120: tidy up devpriv->mode in apci3120_ai_cmd()

There is no reason for the separate updates of the mode register in this
function. Refactor the code so that the mode register is only updated at
the end of the function after all the necessary bits have been set.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fdeb2f54
...@@ -373,8 +373,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, ...@@ -373,8 +373,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
struct comedi_cmd *cmd = &s->async->cmd; struct comedi_cmd *cmd = &s->async->cmd;
unsigned int divisor; unsigned int divisor;
devpriv->mode = 0; /* set default mode bits */
outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG); devpriv->mode = APCI3120_MODE_TIMER2_CLK_OSC |
APCI3120_MODE_TIMER2_AS_TIMER;
/* Clear Timer Write TC int */ /* Clear Timer Write TC int */
outl(APCI3120_CLEAR_WRITE_TC_INT, outl(APCI3120_CLEAR_WRITE_TC_INT,
...@@ -415,11 +416,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev, ...@@ -415,11 +416,9 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
devpriv->b_InterruptMode = APCI3120_DMA_MODE; devpriv->b_InterruptMode = APCI3120_DMA_MODE;
apci3120_setup_dma(dev, s); apci3120_setup_dma(dev, s);
} else { } else {
/* disable EOC and enable EOS */
devpriv->b_InterruptMode = APCI3120_EOS_MODE; devpriv->b_InterruptMode = APCI3120_EOS_MODE;
devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA; devpriv->mode |= APCI3120_MODE_EOS_IRQ_ENA;
outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG);
if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_src == TRIG_COUNT) {
/* /*
...@@ -439,13 +438,15 @@ static int apci3120_ai_cmd(struct comedi_device *dev, ...@@ -439,13 +438,15 @@ static int apci3120_ai_cmd(struct comedi_device *dev,
devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER | devpriv->mode |= APCI3120_MODE_TIMER2_AS_COUNTER |
APCI3120_MODE_TIMER2_CLK_EOS | APCI3120_MODE_TIMER2_CLK_EOS |
APCI3120_MODE_TIMER2_IRQ_ENA; APCI3120_MODE_TIMER2_IRQ_ENA;
outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG);
devpriv->b_Timer2Mode = APCI3120_COUNTER; devpriv->b_Timer2Mode = APCI3120_COUNTER;
devpriv->b_Timer2Interrupt = 1; devpriv->b_Timer2Interrupt = 1;
} }
} }
/* set mode to enable acquisition */
outb(devpriv->mode, dev->iobase + APCI3120_MODE_REG);
if (cmd->scan_begin_src == TRIG_TIMER) if (cmd->scan_begin_src == TRIG_TIMER)
apci3120_timer_enable(dev, 1, true); apci3120_timer_enable(dev, 1, true);
apci3120_timer_enable(dev, 0, true); apci3120_timer_enable(dev, 0, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment