From f6085cb45b0805f9daee9b68079c1a33c039d7ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:08 -0700 Subject: [PATCH] staging: comedi: rti802: use comedi_subdevice 'readback' Use the new comedi_subdevice 'readback' member and the core provided (*insn_read) for the readback of the analog output subdevice channels. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rti802.c | 29 +++++++------------------ 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 605a31d702e0..c81b01c40f12 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -45,24 +45,8 @@ struct rti802_private { dac_2comp, dac_straight } dac_coding[8]; const struct comedi_lrange *range_type_list[8]; - unsigned int ao_readback[8]; }; -static int rti802_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct rti802_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; - - return insn->n; -} - static int rti802_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -70,15 +54,14 @@ static int rti802_ao_insn_write(struct comedi_device *dev, { struct rti802_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int val; int i; outb(chan, dev->iobase + RTI802_SELECT); for (i = 0; i < insn->n; i++) { - val = data[i]; + unsigned int val = data[i]; - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; /* munge offset binary to two's complement if needed */ if (devpriv->dac_coding[chan] == dac_2comp) @@ -116,10 +99,14 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE; s->maxdata = 0xfff; s->n_chan = 8; - s->insn_read = rti802_ao_insn_read; s->insn_write = rti802_ao_insn_write; - s->range_table_list = devpriv->range_type_list; + s->insn_read = comedi_readback_insn_read; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + + s->range_table_list = devpriv->range_type_list; for (i = 0; i < 8; i++) { devpriv->dac_coding[i] = (it->options[3 + 2 * i]) ? (dac_straight) : (dac_2comp); -- 2.39.5