summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-20 15:07:27 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:39:16 -0800
commita1c76758987eac334a7dffcb0b50e597da4ded77 (patch)
treeaecf8d6e5f3924c8043ff6af4dbb44187a78bb60 /drivers/staging/comedi
parent7a82a2c4e4aa0cdace951cf35c266d02fb96039f (diff)
downloadop-kernel-dev-a1c76758987eac334a7dffcb0b50e597da4ded77.zip
op-kernel-dev-a1c76758987eac334a7dffcb0b50e597da4ded77.tar.gz
staging: comedi: cb_pcidas: use subdevice readback for 'trimpot_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only trimpot calib subdevice. Remove the then unused 'trimpot_value' member from the private data. 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.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index d5edb5f..86e3d20 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -356,7 +356,6 @@ struct cb_pcidas_private {
/* divisors of master clock for analog output pacing */
unsigned int ao_divisor1;
unsigned int ao_divisor2;
- unsigned int trimpot_value[NUM_CHANNELS_8402];
unsigned int dac08_value;
unsigned int calibration_source;
};
@@ -744,33 +743,20 @@ static int cb_pcidas_trimpot_insn_write(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
- 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) {
+ if (s->readback[chan] != val) {
cb_pcidas_trimpot_write(dev, chan, val);
- devpriv->trimpot_value[chan] = val;
+ s->readback[chan] = val;
}
}
return insn->n;
}
-static int trimpot_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- struct cb_pcidas_private *devpriv = dev->private;
- unsigned int channel = CR_CHAN(insn->chanspec);
-
- data[0] = devpriv->trimpot_value[channel];
-
- return 1;
-}
-
static int cb_pcidas_ai_check_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
@@ -1527,11 +1513,15 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
s->n_chan = NUM_CHANNELS_8402;
s->maxdata = 0xff;
}
- s->insn_read = trimpot_read_insn;
s->insn_write = cb_pcidas_trimpot_insn_write;
+
+ ret = comedi_alloc_subdev_readback(s);
+ if (ret)
+ return ret;
+
for (i = 0; i < s->n_chan; i++) {
cb_pcidas_trimpot_write(dev, i, s->maxdata / 2);
- devpriv->trimpot_value[i] = s->maxdata / 2;
+ s->readback[i] = s->maxdata / 2;
}
/* dac08 caldac */
OpenPOWER on IntegriCloud