From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:38 +0000 (-0700) Subject: staging: comedi: rti800: save unmunged data for ao readback X-Git-Tag: v3.18-rc1~130^2~1014 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6dc125d2bea484ecee91e43f7ca5ba43d306480b;p=karo-tx-linux.git staging: comedi: rti800: save unmunged data for ao readback The unmunged data should be saved for readback not the munged data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 2b1db9783bd6..01ec65a5b5d1 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -231,11 +231,13 @@ static int rti800_ao_insn_write(struct comedi_device *dev, unsigned int chan = CR_CHAN(insn->chanspec); int reg_lo = chan ? RTI800_DAC1LO : RTI800_DAC0LO; int reg_hi = chan ? RTI800_DAC1HI : RTI800_DAC0HI; - int val = devpriv->ao_readback[chan]; int i; for (i = 0; i < insn->n; i++) { - val = data[i]; + unsigned int val = data[i]; + + devpriv->ao_readback[chan] = val; + if (devpriv->dac_2comp[chan]) val ^= 0x800; @@ -243,8 +245,6 @@ static int rti800_ao_insn_write(struct comedi_device *dev, outb((val >> 8) & 0xff, dev->iobase + reg_hi); } - devpriv->ao_readback[chan] = val; - return insn->n; }