summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-03-22 09:47:51 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 11:42:58 -0700
commit8a67a67f45b1393a4cf656b89afa99202adb041c (patch)
tree5e01d9e436ea50b0330a919f1c32eadfa05d9b86
parent9718e5dfd7e19a2fb0d98a9afdb0459ba6b5d41f (diff)
staging: comedi: ni_labpc: cleanup local var declarations in labpc_ai_cmd()
Determine the scan_mode early and get the proper chanspec so that the chan, range, and aref can be determined when the variables are declared. labpc_ai_chanlist_invalid() checks that all the range and aref values in the chanlist are the same so, for consistency, use the same chanspec used to get the chan. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 56d60847f820..3672ba897b86 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -850,16 +850,18 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct labpc_boardinfo *board = comedi_board(dev);
struct labpc_private *devpriv = dev->private;
- int channel, range, aref;
- int ret;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+ enum scan_mode mode = labpc_ai_scan_mode(cmd);
+ unsigned int chanspec = (mode == MODE_MULT_CHAN_UP)
+ ? cmd->chanlist[cmd->chanlist_len - 1]
+ : cmd->chanlist[0];
+ unsigned int chan = CR_CHAN(chanspec);
+ unsigned int range = CR_RANGE(chanspec);
+ unsigned int aref = CR_AREF(chanspec);
enum transfer_type xfer;
- enum scan_mode mode;
unsigned long flags;
-
- range = CR_RANGE(cmd->chanlist[0]);
- aref = CR_AREF(cmd->chanlist[0]);
+ int ret;
/* make sure board is disabled before setting up acquisition */
spin_lock_irqsave(&dev->spinlock, flags);
@@ -916,7 +918,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
} else
xfer = fifo_not_empty_transfer;
devpriv->current_transfer = xfer;
- mode = labpc_ai_scan_mode(cmd);
/* setup cmd6 register for 1200 boards */
if (board->register_layout == labpc_1200_layout) {
@@ -951,15 +952,11 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* setup channel list, etc (cmd1 register) */
devpriv->cmd1 = 0;
- if (mode == MODE_MULT_CHAN_UP)
- channel = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]);
- else
- channel = CR_CHAN(cmd->chanlist[0]);
/* munge channel bits for differential / scan disabled mode */
if ((mode == MODE_SINGLE_CHAN || mode == MODE_SINGLE_CHAN_INTERVAL) &&
aref == AREF_DIFF)
- channel *= 2;
- devpriv->cmd1 |= ADC_CHAN_BITS(channel);
+ chan *= 2;
+ devpriv->cmd1 |= ADC_CHAN_BITS(chan);
devpriv->cmd1 |= board->ai_range_code[range];
devpriv->write_byte(devpriv->cmd1, dev->iobase + COMMAND1_REG);
/* manual says to set scan enable bit on second pass */