]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: das08: fix bug in das08_ao_winsn()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 25 Aug 2014 23:04:36 +0000 (16:04 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Aug 2014 20:22:33 +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. Fix it to work
like the core expects.

For aesthetics, rename the function and tidy it up a bit.

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

index 03b2c71df8f88c0af664c4da7be08f778ae7cd8c..9a5a06b79a615f93ad5daa57156139ed380e91fe 100644 (file)
@@ -369,19 +369,18 @@ static void das08_ao_initialize(struct comedi_device *dev,
                das08_ao_set_data(dev, n, data);
 }
 
-static int das08_ao_winsn(struct comedi_device *dev,
-                         struct comedi_subdevice *s,
-                         struct comedi_insn *insn, unsigned int *data)
+static int das08_ao_insn_write(struct comedi_device *dev,
+                              struct comedi_subdevice *s,
+                              struct comedi_insn *insn,
+                              unsigned int *data)
 {
-       unsigned int n;
-       unsigned int chan;
-
-       chan = CR_CHAN(insn->chanspec);
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       int i;
 
-       for (n = 0; n < insn->n; n++)
-               das08_ao_set_data(dev, chan, *data);
+       for (i = 0; i < insn->n; i++)
+               das08_ao_set_data(dev, chan, data[i]);
 
-       return n;
+       return insn->n;
 }
 
 static int das08_ao_rinsn(struct comedi_device *dev,
@@ -498,7 +497,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                s->n_chan = 2;
                s->maxdata = (1 << thisboard->ao_nbits) - 1;
                s->range_table = &range_bipolar5;
-               s->insn_write = das08_ao_winsn;
+               s->insn_write = das08_ao_insn_write;
                s->insn_read = das08_ao_rinsn;
                das08_ao_initialize(dev, s);
        } else {