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

staging: comedi: fl512: tidy up fl512_ao_insn_read()

Tidy up this function.
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 3ecbbb56
...@@ -52,22 +52,26 @@ static int fl512_ai_insn_read(struct comedi_device *dev, ...@@ -52,22 +52,26 @@ static int fl512_ai_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
int n; unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int lo_byte, hi_byte; unsigned int val;
char chan = CR_CHAN(insn->chanspec); int i;
for (n = 0; n < insn->n; n++) { /* sample n times on selected channel */ outb(chan, dev->iobase + FL512_AI_MUX_REG);
/* XXX probably can move next step out of for() loop -- will
* make AI a little bit faster. */ for (i = 0; i < insn->n; i++) {
outb(chan, dev->iobase + FL512_AI_MUX_REG);
outb(0, dev->iobase + FL512_AI_START_CONV_REG); outb(0, dev->iobase + FL512_AI_START_CONV_REG);
/* XXX should test "done" flag instead of delay */ /* XXX should test "done" flag instead of delay */
udelay(30); /* sleep 30 usec */ udelay(30);
lo_byte = inb(dev->iobase + FL512_AI_LSB_REG);
hi_byte = inb(dev->iobase + FL512_AI_MSB_REG) & 0xf; val = inb(dev->iobase + FL512_AI_LSB_REG);
data[n] = lo_byte + (hi_byte << 8); val |= (inb(dev->iobase + FL512_AI_MSB_REG) << 8);
val &= s->maxdata;
data[i] = val;
} }
return n;
return insn->n;
} }
static int fl512_ao_insn_write(struct comedi_device *dev, static int fl512_ao_insn_write(struct comedi_device *dev,
......
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