Commit afdc37ee authored by Fred Akers's avatar Fred Akers Committed by Greg Kroah-Hartman

Staging: comedi: range: tidy up comedi_check_chanlist()

Refactor this function to remove an extra indent level
Signed-off-by: default avatarFred Akers <knivey@botops.net>
Reviewed-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 f3c25d56
...@@ -143,29 +143,28 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, ...@@ -143,29 +143,28 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n,
unsigned int chanspec; unsigned int chanspec;
int chan, range_len, i; int chan, range_len, i;
if (s->range_table || s->range_table_list) { if (!s->range_table && !s->range_table_list) {
for (i = 0; i < n; i++) {
chanspec = chanlist[i];
chan = CR_CHAN(chanspec);
if (s->range_table)
range_len = s->range_table->length;
else if (s->range_table_list && chan < s->n_chan)
range_len = s->range_table_list[chan]->length;
else
range_len = 0;
if (chan >= s->n_chan ||
CR_RANGE(chanspec) >= range_len ||
aref_invalid(s, chanspec)) {
dev_warn(dev->class_dev,
"bad chanlist[%d]=0x%08x chan=%d range length=%d\n",
i, chanspec, chan, range_len);
return -EINVAL;
}
}
} else {
dev_err(dev->class_dev, "(bug) no range type list!\n"); dev_err(dev->class_dev, "(bug) no range type list!\n");
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < n; i++) {
chanspec = chanlist[i];
chan = CR_CHAN(chanspec);
if (s->range_table)
range_len = s->range_table->length;
else if (s->range_table_list && chan < s->n_chan)
range_len = s->range_table_list[chan]->length;
else
range_len = 0;
if (chan >= s->n_chan ||
CR_RANGE(chanspec) >= range_len ||
aref_invalid(s, chanspec)) {
dev_warn(dev->class_dev,
"bad chanlist[%d]=0x%08x chan=%d range length=%d\n",
i, chanspec, chan, range_len);
return -EINVAL;
}
}
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(comedi_check_chanlist); EXPORT_SYMBOL_GPL(comedi_check_chanlist);
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