Commit 73f2b1d2 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_labpc: cleanup local var declarations in labpc_ai_insn_read()

Determine the chan, range, and aref when the variables are declared.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8a67a67f
...@@ -370,11 +370,13 @@ static int labpc_ai_insn_read(struct comedi_device *dev, ...@@ -370,11 +370,13 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
{ {
const struct labpc_boardinfo *board = comedi_board(dev); const struct labpc_boardinfo *board = comedi_board(dev);
struct labpc_private *devpriv = dev->private; struct labpc_private *devpriv = dev->private;
int i, n; unsigned int chan = CR_CHAN(insn->chanspec);
int chan, range; unsigned int range = CR_RANGE(insn->chanspec);
int lsb, msb; unsigned int aref = CR_AREF(insn->chanspec);
int timeout = 1000; int timeout = 1000;
unsigned long flags; unsigned long flags;
int lsb, msb;
int i, n;
/* disable timed conversions */ /* disable timed conversions */
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
...@@ -388,11 +390,9 @@ static int labpc_ai_insn_read(struct comedi_device *dev, ...@@ -388,11 +390,9 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
/* set gain and channel */ /* set gain and channel */
devpriv->cmd1 = 0; devpriv->cmd1 = 0;
chan = CR_CHAN(insn->chanspec);
range = CR_RANGE(insn->chanspec);
devpriv->cmd1 |= board->ai_range_code[range]; devpriv->cmd1 |= board->ai_range_code[range];
/* munge channel bits for differential/scan disabled mode */ /* munge channel bits for differential/scan disabled mode */
if (CR_AREF(insn->chanspec) == AREF_DIFF) if (aref == AREF_DIFF)
chan *= 2; chan *= 2;
devpriv->cmd1 |= ADC_CHAN_BITS(chan); devpriv->cmd1 |= ADC_CHAN_BITS(chan);
devpriv->write_byte(devpriv->cmd1, dev->iobase + COMMAND1_REG); devpriv->write_byte(devpriv->cmd1, dev->iobase + COMMAND1_REG);
...@@ -400,7 +400,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev, ...@@ -400,7 +400,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
/* setup cmd6 register for 1200 boards */ /* setup cmd6 register for 1200 boards */
if (board->register_layout == labpc_1200_layout) { if (board->register_layout == labpc_1200_layout) {
/* reference inputs to ground or common? */ /* reference inputs to ground or common? */
if (CR_AREF(insn->chanspec) != AREF_GROUND) if (aref != AREF_GROUND)
devpriv->cmd6 |= ADC_COMMON_BIT; devpriv->cmd6 |= ADC_COMMON_BIT;
else else
devpriv->cmd6 &= ~ADC_COMMON_BIT; devpriv->cmd6 &= ~ADC_COMMON_BIT;
...@@ -420,7 +420,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev, ...@@ -420,7 +420,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
devpriv->cmd4 = 0; devpriv->cmd4 = 0;
devpriv->cmd4 |= EXT_CONVERT_DISABLE_BIT; devpriv->cmd4 |= EXT_CONVERT_DISABLE_BIT;
/* single-ended/differential */ /* single-ended/differential */
if (CR_AREF(insn->chanspec) == AREF_DIFF) if (aref == AREF_DIFF)
devpriv->cmd4 |= ADC_DIFF_BIT; devpriv->cmd4 |= ADC_DIFF_BIT;
devpriv->write_byte(devpriv->cmd4, dev->iobase + COMMAND4_REG); devpriv->write_byte(devpriv->cmd4, dev->iobase + COMMAND4_REG);
......
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