diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2014-11-20 22:07:25 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-26 23:39:16 (GMT) |
commit | 3f5ced0d0241d64b43c33402e714198824d5b0de (patch) | |
tree | 511bee88815292a78514997e79322683b2d1b703 | |
parent | f52e5e44a9eedc1649bf65f28d6ad69a46c54f10 (diff) | |
download | linux-3f5ced0d0241d64b43c33402e714198824d5b0de.tar.xz |
staging: comedi: cb_pcidas: use subdevice readback for 'caldac_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the write-only caldac subdevice. Remove the then
unused 'caldac_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>
-rw-r--r-- | drivers/staging/comedi/drivers/cb_pcidas.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index d33b37c..f92ad26 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 caldac_value[NUM_CHANNELS_8800]; unsigned int trimpot_value[NUM_CHANNELS_8402]; unsigned int dac08_value; unsigned int calibration_source; @@ -615,32 +614,20 @@ static int cb_pcidas_caldac_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->caldac_value[chan] != val) { + if (s->readback[chan] != val) { caldac_8800_write(dev, chan, val); - devpriv->caldac_value[chan] = val; + s->readback[chan] = val; } } return insn->n; } -static int caldac_read_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct cb_pcidas_private *devpriv = dev->private; - - data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - /* 1602/16 pregain offset */ static void dac08_write(struct comedi_device *dev, unsigned int value) { @@ -1514,11 +1501,15 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->n_chan = NUM_CHANNELS_8800; s->maxdata = 0xff; - s->insn_read = caldac_read_insn; s->insn_write = cb_pcidas_caldac_insn_write; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + for (i = 0; i < s->n_chan; i++) { caldac_8800_write(dev, i, s->maxdata / 2); - devpriv->caldac_value[i] = s->maxdata / 2; + s->readback[i] = s->maxdata / 2; } /* trim potentiometer */ |