diff options
author | Fred Akers <knivey@botops.net> | 2014-03-06 01:57:18 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-08 18:59:48 -0800 |
commit | afdc37ee79cd53aad24dd995a1fc55568e4c0baa (patch) | |
tree | f4c193c604f5e3da8662182757dd5ff71bd14cb9 /drivers/staging | |
parent | f3c25d569045c8e0f274956291b51641241da174 (diff) | |
download | linux-afdc37ee79cd53aad24dd995a1fc55568e4c0baa.tar.bz2 |
Staging: comedi: range: tidy up comedi_check_chanlist()
Refactor this function to remove an extra indent level
Signed-off-by: Fred Akers <knivey@botops.net>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/range.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c index 46b3da686384..c4bb13bab934 100644 --- a/drivers/staging/comedi/range.c +++ b/drivers/staging/comedi/range.c @@ -143,29 +143,28 @@ int comedi_check_chanlist(struct comedi_subdevice *s, int n, unsigned int chanspec; int chan, range_len, i; - 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 { + if (!s->range_table && !s->range_table_list) { dev_err(dev->class_dev, "(bug) no range type list!\n"); 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; } EXPORT_SYMBOL_GPL(comedi_check_chanlist); |