summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-20 15:07:26 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:39:16 -0800
commit7a82a2c4e4aa0cdace951cf35c266d02fb96039f (patch)
treec00f6d118016d0c9ea8705d56c2a475b96cfaa3f /drivers/staging/comedi
parent3f5ced0d0241d64b43c33402e714198824d5b0de (diff)
downloadop-kernel-dev-7a82a2c4e4aa0cdace951cf35c266d02fb96039f.zip
op-kernel-dev-7a82a2c4e4aa0cdace951cf35c266d02fb96039f.tar.gz
staging: comedi: cb_pcidas: fix trimpot_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')
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index f92ad26..d5edb5f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -721,38 +721,42 @@ static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
return 0;
}
-static int cb_pcidas_trimpot_write(struct comedi_device *dev,
- unsigned int channel, unsigned int value)
+static void cb_pcidas_trimpot_write(struct comedi_device *dev,
+ unsigned int chan, unsigned int val)
{
const struct cb_pcidas_board *thisboard = dev->board_ptr;
- struct cb_pcidas_private *devpriv = dev->private;
-
- if (devpriv->trimpot_value[channel] == value)
- return 1;
- devpriv->trimpot_value[channel] = value;
switch (thisboard->trimpot) {
case AD7376:
- trimpot_7376_write(dev, value);
+ trimpot_7376_write(dev, val);
break;
case AD8402:
- trimpot_8402_write(dev, channel, value);
+ trimpot_8402_write(dev, chan, val);
break;
default:
dev_err(dev->class_dev, "driver bug?\n");
- return -1;
+ break;
}
-
- return 1;
}
-static int trimpot_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int cb_pcidas_trimpot_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- unsigned int channel = CR_CHAN(insn->chanspec);
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+
+ if (insn->n) {
+ unsigned int val = data[insn->n - 1];
+
+ if (devpriv->trimpot_value[chan] != val) {
+ cb_pcidas_trimpot_write(dev, chan, val);
+ devpriv->trimpot_value[chan] = val;
+ }
+ }
- return cb_pcidas_trimpot_write(dev, channel, data[0]);
+ return insn->n;
}
static int trimpot_read_insn(struct comedi_device *dev,
@@ -1524,9 +1528,11 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
s->maxdata = 0xff;
}
s->insn_read = trimpot_read_insn;
- s->insn_write = trimpot_write_insn;
- for (i = 0; i < s->n_chan; i++)
+ s->insn_write = cb_pcidas_trimpot_insn_write;
+ for (i = 0; i < s->n_chan; i++) {
cb_pcidas_trimpot_write(dev, i, s->maxdata / 2);
+ devpriv->trimpot_value[i] = s->maxdata / 2;
+ }
/* dac08 caldac */
s = &dev->subdevices[6];
OpenPOWER on IntegriCloud