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

staging: comedi: me4000: use comedi_range_is_bipolar() in ai (*insn_read)

Use the helper function to check the range type instead of relying on the
value. For aesthetics, rename the local variable used for the range.
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 959717a3
...@@ -452,15 +452,14 @@ static int me4000_ai_insn_read(struct comedi_device *dev, ...@@ -452,15 +452,14 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
unsigned int *data) unsigned int *data)
{ {
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int rang = CR_RANGE(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec);
unsigned int entry = 0; unsigned int entry;
unsigned int tmp; unsigned int tmp;
int ret; int ret;
int i; int i;
entry |= ME4000_AI_LIST_RANGE(rang); entry = chan | ME4000_AI_LIST_RANGE(range);
entry |= chan;
if (aref == AREF_DIFF) { if (aref == AREF_DIFF) {
if (!(s->subdev_flags && SDF_DIFF)) { if (!(s->subdev_flags && SDF_DIFF)) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
...@@ -468,7 +467,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev, ...@@ -468,7 +467,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL; return -EINVAL;
} }
if (rang == 0 || rang == 1) { if (!comedi_range_is_bipolar(s, range)) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
"Range must be bipolar when aref = diff\n"); "Range must be bipolar when aref = diff\n");
return -EINVAL; return -EINVAL;
......
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