]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: me_daq: fix bug in me_ao_insn_write()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:28 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:32 +0000 (13:22 -0700)
The comedi core expects (*insn_write) functions to write insn->n values
to the hardware and return the number of values written.

Currently, this function only writes the first value. The core also
validates all the data values so the extra masking with s->maxdata is
not needed. Fix this function to work like the core expects.

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/me_daq.c

index 37a6fa92c656ab3599338eed1b71cb28296cc73c..df1fceb3c53fd9fa07817791af3683fd6fb345fa 100644 (file)
@@ -325,6 +325,7 @@ static int me_ao_insn_write(struct comedi_device *dev,
        struct me_private_data *dev_private = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int rang = CR_RANGE(insn->chanspec);
+       unsigned int val = dev_private->ao_readback[chan];
        int i;
 
        /* Enable all DAC */
@@ -353,10 +354,11 @@ static int me_ao_insn_write(struct comedi_device *dev,
 
        /* Set data register */
        for (i = 0; i < insn->n; i++) {
-               writew((data[0] & s->maxdata),
-                      dev->mmio + ME_DAC_DATA_A + (chan << 1));
-               dev_private->ao_readback[chan] = (data[0] & s->maxdata);
+               val = data[i];
+
+               writew(val, dev->mmio + ME_DAC_DATA_A + (chan << 1));
        }
+       dev_private->ao_readback[chan] = val;
 
        /* Update dac with data registers */
        readw(dev->mmio + ME_DAC_UPDATE);