staging: comedi: ni_labpc_common: use subdevice readback for 'caldac'
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' 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>
This commit is contained in:
parent
332f46e4be
commit
1e3d3a4d1b
|
@ -72,8 +72,6 @@ struct labpc_private {
|
|||
enum transfer_type current_transfer;
|
||||
/* stores contents of board's eeprom */
|
||||
unsigned int eeprom_data[EEPROM_SIZE];
|
||||
/* stores settings of calibration dacs */
|
||||
unsigned int caldac[16];
|
||||
/*
|
||||
* function pointers so we can use inb/outb or readb/writeb as
|
||||
* appropriate
|
||||
|
|
|
@ -1174,7 +1174,6 @@ static int labpc_calib_insn_write(struct comedi_device *dev,
|
|||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct labpc_private *devpriv = dev->private;
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
|
||||
/*
|
||||
|
@ -1184,30 +1183,15 @@ static int labpc_calib_insn_write(struct comedi_device *dev,
|
|||
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,
|
||||
|
@ -1345,12 +1329,15 @@ int labpc_common_attach(struct comedi_device *dev,
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue