From 35e769c4717cf08f71cd5c7a9e34aece3ff8852e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:39 -0700 Subject: [PATCH] staging: comedi: rti800: 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/rti800.c | 26 +++++++------------------ 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 01ec65a5b5d1..4df979e519f0 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -137,7 +137,6 @@ struct rti800_private { bool adc_2comp; bool dac_2comp[2]; const struct comedi_lrange *ao_range_type_list[2]; - unsigned int ao_readback[2]; unsigned char muxgain_bits; }; @@ -207,21 +206,6 @@ static int rti800_ai_insn_read(struct comedi_device *dev, return insn->n; } -static int rti800_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct rti800_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 rti800_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -236,7 +220,7 @@ static int rti800_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { unsigned int val = data[i]; - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; if (devpriv->dac_2comp[chan]) val ^= 0x800; @@ -318,8 +302,6 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; - s->insn_read = rti800_ao_insn_read; - s->insn_write = rti800_ao_insn_write; s->maxdata = 0x0fff; s->range_table_list = devpriv->ao_range_type_list; devpriv->ao_range_type_list[0] = @@ -330,6 +312,12 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it) (it->options[7] < ARRAY_SIZE(rti800_ao_ranges)) ? rti800_ao_ranges[it->options[7]] : &range_unknown; + s->insn_write = rti800_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; } else { s->type = COMEDI_SUBD_UNUSED; } -- 2.39.5