aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/dmm32at.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-11 16:55:20 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:33:23 -0800
commit01b7ecdd9529fd5722b9b18424f510cc34cc8e85 (patch)
tree7d0d4072cd987276307dc51e6fdc997946cda073 /drivers/staging/comedi/drivers/dmm32at.c
parentstaging: comedi: dmm32at: introduce dmm32_ai_get_sample() (diff)
downloadlinux-dev-01b7ecdd9529fd5722b9b18424f510cc34cc8e85.tar.xz
linux-dev-01b7ecdd9529fd5722b9b18424f510cc34cc8e85.zip
staging: comedi: dmm32at: tidy up dmm32at_ai_rinsn()
For aesthetics, rename this function to dmm32at_ai_insn_read(). Get the 'chan' and 'range' from the chanspec when declaring the local variables. Remove the unecessary masking of the 'chan'. Remove some unnecessary comments. Change the final return to 'insn->n' to clarify the return value. 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/comedi/drivers/dmm32at.c')
-rw-r--r--drivers/staging/comedi/drivers/dmm32at.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index b90f61965396..b21d08df4555 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -181,27 +181,22 @@ static int dmm32at_ai_status(struct comedi_device *dev,
return -EBUSY;
}
-static int dmm32at_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_ai_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- int n;
- unsigned char chan;
- int range;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int range = CR_RANGE(insn->chanspec);
int ret;
-
- /* get the channel and range number */
-
- chan = CR_CHAN(insn->chanspec) & (s->n_chan - 1);
- range = CR_RANGE(insn->chanspec);
+ int i;
/* zero scan and fifo control and reset fifo */
outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL);
- /* write the ai channel range regs */
+ /* set the channel and range */
outb(chan, dev->iobase + DMM32AT_AILOW);
outb(chan, dev->iobase + DMM32AT_AIHIGH);
- /* set the range bits */
outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF);
/* wait for circuit to settle */
@@ -209,22 +204,18 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
if (ret)
return ret;
- /* convert n samples */
- for (n = 0; n < insn->n; n++) {
- /* trigger conversion */
+ for (i = 0; i < insn->n; i++) {
outb(0xff, dev->iobase + DMM32AT_CONV);
- /* wait for conversion to end */
ret = comedi_timeout(dev, s, insn, dmm32at_ai_status,
DMM32AT_AISTAT);
if (ret)
return ret;
- data[n] = dmm32at_ai_get_sample(dev, s);
+ data[i] = dmm32at_ai_get_sample(dev, s);
}
- /* return the number of samples read/written */
- return n;
+ return insn->n;
}
static int dmm32at_ns_to_timer(unsigned int *ns, unsigned int flags)
@@ -693,7 +684,7 @@ static int dmm32at_attach(struct comedi_device *dev,
s->n_chan = 32;
s->maxdata = 0xffff;
s->range_table = &dmm32at_airanges;
- s->insn_read = dmm32at_ai_rinsn;
+ s->insn_read = dmm32at_ai_insn_read;
if (dev->irq) {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;