aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/cb_pcidas64.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-20 15:07:22 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:39:16 -0800
commitdc658fdc8a807c5b5a405277685f35e53673729c (patch)
tree49c82bd6b4aadee6d84f07cbc6d6c891dff35766 /drivers/staging/comedi/drivers/cb_pcidas64.c
parentstaging: comedi: cb_pcidas64: use subdevice readback for 'ad8402_state' (diff)
downloadlinux-dev-dc658fdc8a807c5b5a405277685f35e53673729c.tar.xz
linux-dev-dc658fdc8a807c5b5a405277685f35e53673729c.zip
staging: comedi: cb_pcidas64: fix ad8402_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 <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/cb_pcidas64.c')
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index d80f34d35ee3..eddb7ace43df 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -3614,22 +3614,27 @@ static void ad8402_write(struct comedi_device *dev, unsigned int channel,
}
/* for pci-das6402/16, channel 0 is analog input gain and channel 1 is offset */
-static int ad8402_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int cb_pcidas64_ad8402_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- int channel = 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;
+ unsigned int chan = CR_CHAN(insn->chanspec);
- s->readback[channel] = data[0];
+ /*
+ * 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];
- ad8402_write(dev, channel, data[0]);
+ if (s->readback[chan] != val) {
+ ad8402_write(dev, chan, val);
+ s->readback[chan] = val;
+ }
+ }
- return 1;
+ return insn->n;
}
static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address)
@@ -3855,7 +3860,7 @@ static int setup_subdevices(struct comedi_device *dev)
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = 2;
s->maxdata = 0xff;
- s->insn_write = ad8402_write_insn;
+ s->insn_write = cb_pcidas64_ad8402_insn_write;
ret = comedi_alloc_subdev_readback(s);
if (ret)