From: H Hartley Sweeten <hartleys@xxxxxxxxxxxxxxxxxxx> Tidy up this function. Only save the last value written for readback. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/fl512.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 8cb1f1e..90a8fd9 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -76,20 +76,21 @@ static int fl512_ao_insn_write(struct comedi_device *dev, unsigned int *data) { struct fl512_private *devpriv = dev->private; - int n; - int chan = CR_CHAN(insn->chanspec); /* get chan to write */ - - for (n = 0; n < insn->n; n++) { /* write n data set */ - /* write low byte */ - outb(data[n] & 0x0ff, dev->iobase + FL512_AO_DATA_REG(chan)); - /* write high byte */ - outb((data[n] & 0xf00) >> 8, - dev->iobase + FL512_AO_DATA_REG(chan)); - inb(dev->iobase + FL512_AO_TRIG_REG(chan)); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val = devpriv->ao_readback[chan]; + int i; + + for (i = 0; i < insn->n; i++) { + val = data[i]; - devpriv->ao_readback[chan] = data[n]; + /* write LSB, MSB then trigger conversion */ + outb(val & 0x0ff, dev->iobase + FL512_AO_DATA_REG(chan)); + outb((val >> 8) & 0xf, dev->iobase + FL512_AO_DATA_REG(chan)); + inb(dev->iobase + FL512_AO_TRIG_REG(chan)); } - return n; + devpriv->ao_readback[chan] = val; + + return insn->n; } static int fl512_ao_insn_read(struct comedi_device *dev, -- 1.8.5.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel