aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2014-11-20 15:07:29 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-11-26 15:39:17 -0800
commite42151f945f7b45e6a1634fc3b665b36f5e42a03 (patch)
tree1dd3ca8b2dbad0121ed2b187ba501c22af613024 /drivers/staging/comedi
parent9c034da124d08237fe973ca0073f5f70297b20fb (diff)
staging: comedi: cb_pcidas: use subdevice readback for 'dac08_value'
Use the comedi_subdevice 'readback' member and the core provided (*insn_read) to handle the readback of the write-only dac08 calib subdevice. Remove the then unused 'dac08_value' member from the private data. The dac08 calib subdevice only has one channel. For consistency in the driver, modify the subdevice init so that a loop is used to initialize the channels and readback values. 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.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 04b6d39d1051..669b1703eb99 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 dac08_value;
unsigned int calibration_source;
};
@@ -650,31 +649,20 @@ static int cb_pcidas_dac08_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->dac08_value != val) {
+ if (s->readback[chan] != val) {
dac08_write(dev, val);
- devpriv->dac08_value = val;
+ s->readback[chan] = val;
}
}
return insn->n;
}
-static int dac08_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->dac08_value;
-
- return 1;
-}
-
static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
{
struct cb_pcidas_private *devpriv = dev->private;
@@ -1531,11 +1519,17 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = NUM_CHANNELS_DAC08;
- s->insn_read = dac08_read_insn;
- s->insn_write = cb_pcidas_dac08_insn_write;
s->maxdata = 0xff;
- dac08_write(dev, s->maxdata / 2);
- devpriv->dac08_value = s->maxdata / 2;
+ s->insn_write = cb_pcidas_dac08_insn_write;
+
+ ret = comedi_alloc_subdev_readback(s);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < s->n_chan; i++) {
+ dac08_write(dev, s->maxdata / 2);
+ s->readback[i] = s->maxdata / 2;
+ }
} else
s->type = COMEDI_SUBD_UNUSED;

Privacy Policy