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 <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/dt2801.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index ad8ba0b..03ca80b 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -207,9 +207,7 @@ static const struct dt2801_board boardtypes[] = { }; struct dt2801_private { - const struct comedi_lrange *dac_range_types[2]; - unsigned int ao_readback[2]; }; /* These are the low-level routines: @@ -465,28 +463,18 @@ static int dt2801_ai_insn_read(struct comedi_device *dev, return i; } -static int dt2801_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct dt2801_private *devpriv = dev->private; - - data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; - - return 1; -} - static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct dt2801_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); dt2801_writecmd(dev, DT_C_WRITE_DAIM); - dt2801_writedata(dev, CR_CHAN(insn->chanspec)); + dt2801_writedata(dev, chan); dt2801_writedata2(dev, data[0]); - devpriv->ao_readback[CR_CHAN(insn->chanspec)] = data[0]; + s->readback[chan] = data[0]; return 1; } @@ -610,8 +598,12 @@ havetype: s->range_table_list = devpriv->dac_range_types; devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]); devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]); - s->insn_read = dt2801_ao_insn_read; s->insn_write = dt2801_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[2]; /* 1st digital subdevice */ -- 2.0.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel