From: H Hartley Sweeten Date: Thu, 13 Mar 2014 17:10:00 +0000 (-0700) Subject: staging: comedi: fl512: tidy up fl512_ao_insn_read() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6632d65e3494f3fb0062b417b6a07086d8a2de70;p=linux-beck.git staging: comedi: fl512: tidy up fl512_ao_insn_read() Tidy up this function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 90a8fd9a7f19..3bf6d6fa12d7 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -52,22 +52,26 @@ static int fl512_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - int n; - unsigned int lo_byte, hi_byte; - char chan = CR_CHAN(insn->chanspec); - - for (n = 0; n < insn->n; n++) { /* sample n times on selected channel */ - /* XXX probably can move next step out of for() loop -- will - * make AI a little bit faster. */ - outb(chan, dev->iobase + FL512_AI_MUX_REG); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val; + int i; + + outb(chan, dev->iobase + FL512_AI_MUX_REG); + + for (i = 0; i < insn->n; i++) { outb(0, dev->iobase + FL512_AI_START_CONV_REG); + /* XXX should test "done" flag instead of delay */ - udelay(30); /* sleep 30 usec */ - lo_byte = inb(dev->iobase + FL512_AI_LSB_REG); - hi_byte = inb(dev->iobase + FL512_AI_MSB_REG) & 0xf; - data[n] = lo_byte + (hi_byte << 8); + udelay(30); + + val = inb(dev->iobase + FL512_AI_LSB_REG); + 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,