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

staging: comedi: cb_pcidas: cleanup cb_pcidas_ai_rinsn()

Create local variables for the channel, range, and aref in order
to make the remaining code a bit cleaner.

Remove the extra space in all the comments.

Remove the 'static const int timeout' and just use the open
coded value in the loop.
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 7671896c
...@@ -382,36 +382,33 @@ static inline unsigned int cal_enable_bits(struct comedi_device *dev) ...@@ -382,36 +382,33 @@ static inline unsigned int cal_enable_bits(struct comedi_device *dev)
return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source); return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
} }
/*
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
static int cb_pcidas_ai_rinsn(struct comedi_device *dev, static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct cb_pcidas_private *devpriv = dev->private; struct cb_pcidas_private *devpriv = dev->private;
int n, i; unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
unsigned int bits; unsigned int bits;
static const int timeout = 10000; int n, i;
int channel;
/* enable calibration input if appropriate */ /* enable calibration input if appropriate */
if (insn->chanspec & CR_ALT_SOURCE) { if (insn->chanspec & CR_ALT_SOURCE) {
outw(cal_enable_bits(dev), outw(cal_enable_bits(dev),
devpriv->control_status + CALIBRATION_REG); devpriv->control_status + CALIBRATION_REG);
channel = 0; chan = 0;
} else { } else {
outw(0, devpriv->control_status + CALIBRATION_REG); outw(0, devpriv->control_status + CALIBRATION_REG);
channel = CR_CHAN(insn->chanspec);
} }
/* set mux limits and gain */
bits = BEGIN_SCAN(channel) | /* set mux limits and gain */
END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec)); bits = BEGIN_SCAN(chan) | END_SCAN(chan) | GAIN_BITS(range);
/* set unipolar/bipolar */ /* set unipolar/bipolar */
if (CR_RANGE(insn->chanspec) & IS_UNIPOLAR) if (range & IS_UNIPOLAR)
bits |= UNIP; bits |= UNIP;
/* set singleended/differential */ /* set single-ended/differential */
if (CR_AREF(insn->chanspec) != AREF_DIFF) if (aref != AREF_DIFF)
bits |= SE; bits |= SE;
outw(bits, devpriv->control_status + ADCMUX_CONT); outw(bits, devpriv->control_status + ADCMUX_CONT);
...@@ -425,11 +422,11 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, ...@@ -425,11 +422,11 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
/* wait for conversion to end */ /* wait for conversion to end */
/* return -ETIMEDOUT if there is a timeout */ /* return -ETIMEDOUT if there is a timeout */
for (i = 0; i < timeout; i++) { for (i = 0; i < 10000; i++) {
if (inw(devpriv->control_status + ADCMUX_CONT) & EOC) if (inw(devpriv->control_status + ADCMUX_CONT) & EOC)
break; break;
} }
if (i == timeout) if (i == 10000)
return -ETIMEDOUT; return -ETIMEDOUT;
/* read data */ /* read data */
......
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