From: H Hartley Sweeten Date: Thu, 20 Nov 2014 22:07:32 +0000 (-0700) Subject: staging: comedi: ni_labpc_common: use subdevice readback for 'caldac' X-Git-Tag: v5.15~16669^2~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e3d3a4d1bba9b7de7f18212954740624cd0448e;p=platform%2Fkernel%2Flinux-starfive.git 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index f6e5cd1..3261e22 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -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 diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 4abca1d..548d3df 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -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;