staging: comedi: rti800: save unmunged data for ao readback
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:38 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:33 +0000 (13:22 -0700)
The unmunged data should be saved for readback not the munged data.

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>
drivers/staging/comedi/drivers/rti800.c

index 2b1db9783bd6489181d5c689927b16e101285ae3..01ec65a5b5d16cde210c1658ef548d84fa770b93 100644 (file)
@@ -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;
 }