]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
staging: comedi: ke_counter: fix ke_counter_insn_write()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 3 Mar 2014 23:47:38 +0000 (16:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Mar 2014 00:40:27 +0000 (16:40 -0800)
The comedi core expects the (*insn_write) functions to write insn->n
values. Fix this function to work like the core expects.

The counters are actually 25-bit (24-bits + 1 sign bit). The comedi core
validates that all the data is in range before calling the (*insn_write),
fix the subdevice maxdata so that the sign bit can actually be changed.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ke_counter.c

index e751482aef194a8eb7bef68ecc97cf058b5435b9..5dfe2bb4c14c54b52b0d0b01e5007e76fed1a1c5 100644 (file)
@@ -54,19 +54,21 @@ static int ke_counter_insn_write(struct comedi_device *dev,
                                 struct comedi_insn *insn,
                                 unsigned int *data)
 {
-       int chan = CR_CHAN(insn->chanspec);
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int val;
+       int i;
 
-       outb((unsigned char)((data[0] >> 24) & 0xff),
-            dev->iobase + KE_SIGN_REG(chan));
-       outb((unsigned char)((data[0] >> 16) & 0xff),
-            dev->iobase + KE_MSB_REG(chan));
-       outb((unsigned char)((data[0] >> 8) & 0xff),
-            dev->iobase + KE_MID_REG(chan));
-       outb((unsigned char)((data[0] >> 0) & 0xff),
-            dev->iobase + KE_LSB_REG(chan));
+       for (i = 0; i < insn->n; i++) {
+               val = data[0];
 
-       /* return the number of samples written */
-       return 1;
+               /* Order matters */
+               outb((val >> 24) & 0xff, dev->iobase + KE_SIGN_REG(chan));
+               outb((val >> 16) & 0xff, dev->iobase + KE_MSB_REG(chan));
+               outb((val >> 8) & 0xff, dev->iobase + KE_MID_REG(chan));
+               outb((val >> 0) & 0xff, dev->iobase + KE_LSB_REG(chan));
+       }
+
+       return insn->n;
 }
 
 static int ke_counter_insn_read(struct comedi_device *dev,
@@ -114,7 +116,7 @@ static int cnt_auto_attach(struct comedi_device *dev,
        s->type         = COMEDI_SUBD_COUNTER;
        s->subdev_flags = SDF_READABLE;
        s->n_chan       = 3;
-       s->maxdata      = 0x00ffffff;
+       s->maxdata      = 0x01ffffff;
        s->range_table  = &range_unknown;
        s->insn_read    = ke_counter_insn_read;
        s->insn_write   = ke_counter_insn_write;