struct comedi_insn *insn,
unsigned int *data)
{
- struct labpc_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
/*
if (insn->n > 0) {
unsigned int val = data[insn->n - 1];
- if (devpriv->caldac[chan] != val) {
+ if (s->readback[chan] != val) {
write_caldac(dev, chan, val);
- devpriv->caldac[chan] = val;
+ s->readback[chan] = val;
}
}
return insn->n;
}
-static int labpc_calib_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- struct labpc_private *devpriv = dev->private;
- unsigned int chan = CR_CHAN(insn->chanspec);
- int i;
-
- for (i = 0; i < insn->n; i++)
- data[i] = devpriv->caldac[chan];
-
- return insn->n;
-}
-
static int labpc_eeprom_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = 16;
s->maxdata = 0xff;
- s->insn_read = labpc_calib_insn_read;
s->insn_write = labpc_calib_insn_write;
+ ret = comedi_alloc_subdev_readback(s);
+ if (ret)
+ return ret;
+
for (i = 0; i < s->n_chan; i++) {
write_caldac(dev, i, s->maxdata / 2);
- devpriv->caldac[i] = s->maxdata / 2;
+ s->readback[i] = s->maxdata / 2;
}
} else {
s->type = COMEDI_SUBD_UNUSED;