Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
function to provide radback of the analog output channels.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 ++
 drivers/staging/comedi/drivers/addi_apci_3120.c           | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 47b1741..c093cd4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1924,6 +1924,8 @@ static int apci3120_ao_insn_write(struct comedi_device 
*dev,
 
                outw(APCI3120_AO_MUX(chan) | APCI3120_AO_DATA(val),
                     dev->iobase + APCI3120_AO_REG(chan));
+
+               s->readback[chan] = val;
        }
 
        return insn->n;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c 
b/drivers/staging/comedi/drivers/addi_apci_3120.c
index abc85bf..5db52cd 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3120.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3120.c
@@ -195,6 +195,11 @@ static int apci3120_auto_attach(struct comedi_device *dev,
                s->maxdata = 0x3fff;
                s->range_table = &range_bipolar10;
                s->insn_write = apci3120_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.0.3

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to