aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <[email protected]>2014-11-20 15:07:20 -0700
committerGreg Kroah-Hartman <[email protected]>2014-11-26 15:39:16 -0800
commit5e2de5e7f9f31db55399e2b4ad3b612dadaf7ebe (patch)
tree2bd7b5916b173aec0ff49cca056d54ab2c4568a8
parent37318bdb14aba8145644c7ca4b76b1ba3efbdcae (diff)
staging: comedi: cb_pcidas64: fix calib_write_insn()
The comedi core expects the (*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. For this subdevice it only makes sense to write the final data value. Fix the function to work like the core expects. For aesthetics, rename the function so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index c641778f3464..17c98a59b44f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -3563,21 +3563,27 @@ static void caldac_write(struct comedi_device *dev, unsigned int channel,
}
}
-static int calib_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int cb_pcidas64_calib_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- int channel = CR_CHAN(insn->chanspec);
+ unsigned int chan = CR_CHAN(insn->chanspec);
- /* return immediately if setting hasn't changed, since
- * programming these things is slow */
- if (s->readback[channel] == data[0])
- return 1;
+ /*
+ * Programming the calib device is slow. Only write the
+ * last data value if the value has changed.
+ */
+ if (insn->n) {
+ unsigned int val = data[insn->n - 1];
- caldac_write(dev, channel, data[0]);
- s->readback[channel] = data[0];
+ if (s->readback[chan] != val) {
+ caldac_write(dev, chan, val);
+ s->readback[chan] = val;
+ }
+ }
- return 1;
+ return insn->n;
}
static void ad8402_write(struct comedi_device *dev, unsigned int channel,
@@ -3848,7 +3854,7 @@ static int setup_subdevices(struct comedi_device *dev)
s->maxdata = 0xfff;
else
s->maxdata = 0xff;
- s->insn_write = calib_write_insn;
+ s->insn_write = cb_pcidas64_calib_insn_write;
ret = comedi_alloc_subdev_readback(s);
if (ret)