staging: comedi: ii_pci20kc: save unmunged data for ao readback
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:30 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:32 +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/ii_pci20kc.c

index 687db433e131d386b70418c6e7431fdcaced0dc6..10e8073dd9190259115d205ecaf79d77be82ea43 100644 (file)
@@ -165,12 +165,14 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
        struct ii20k_ao_private *ao_spriv = s->private;
        void __iomem *iobase = ii20k_module_iobase(dev, s);
        unsigned int chan = CR_CHAN(insn->chanspec);
-       unsigned int val = ao_spriv->last_data[chan];
+       unsigned int val;
        int i;
 
        for (i = 0; i < insn->n; i++) {
                val = data[i];
 
+               ao_spriv->last_data[chan] = val;
+
                /* munge data */
                val += ((s->maxdata + 1) >> 1);
                val &= s->maxdata;
@@ -180,8 +182,6 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
                writeb(0x00, iobase + II20K_AO_STRB_REG(chan));
        }
 
-       ao_spriv->last_data[chan] = val;
-
        return insn->n;
 }