diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-05-28 23:34:48 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-06-18 21:34:44 (GMT) |
commit | d8dc10bf6888b586e284bca3e9f1a9da40590874 (patch) | |
tree | a7c2d2745576615959bd0a9c97d690dce26a5b85 /drivers/staging | |
parent | f93b399b137062b9108b2bd4cbc5f849d983c19f (diff) | |
download | linux-d8dc10bf6888b586e284bca3e9f1a9da40590874.tar.xz |
staging: comedi: adq12b: tidy up adq12b_ai_rinsn()
For aesthetics, rename this function.
Clean up the local variables by reusing 'val' instead of using
separate variables for the:
'status' - use once to trigger the first A/D conversion
'hi' and 'lo' - used to read the A/D conversion result
For aesthetics, change the final return to insn->n and remove the
comment.
Signed-off-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/drivers/adq12b.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index e5b236d..4a0bbd7 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -132,18 +132,17 @@ static int adq12b_ai_eoc(struct comedi_device *dev, return -EBUSY; } -static int adq12b_ai_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int adq12b_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct adq12b_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); unsigned int val; - int n; - unsigned char hi, lo, status; int ret; + int i; /* change channel and range only if it is different from the previous */ val = (range << 4) | chan; @@ -153,27 +152,20 @@ static int adq12b_ai_rinsn(struct comedi_device *dev, udelay(50); /* wait for the mux to settle */ } - /* trigger conversion */ - status = inb(dev->iobase + ADQ12B_ADLOW); + val = inb(dev->iobase + ADQ12B_ADLOW); /* trigger A/D */ - /* convert n samples */ - for (n = 0; n < insn->n; n++) { - - /* wait for end of conversion */ + for (i = 0; i < insn->n; i++) { ret = comedi_timeout(dev, s, insn, adq12b_ai_eoc, 0); if (ret) return ret; - /* read data */ - hi = inb(dev->iobase + ADQ12B_ADHIG); - lo = inb(dev->iobase + ADQ12B_ADLOW); - - data[n] = (hi << 8) | lo; + val = inb(dev->iobase + ADQ12B_ADHIG) << 8; + val |= inb(dev->iobase + ADQ12B_ADLOW); /* retriggers A/D */ + data[i] = val; } - /* return the number of samples read/written */ - return n; + return insn->n; } static int adq12b_di_insn_bits(struct comedi_device *dev, @@ -254,7 +246,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->len_chanlist = 4; /* This is the maximum chanlist length that the board can handle */ - s->insn_read = adq12b_ai_rinsn; + s->insn_read = adq12b_ai_insn_read; s = &dev->subdevices[1]; /* digital input subdevice */ |