[PATCH 14/22] staging: comedi: addi_apci_3120: provide analog output 'readback'

H Hartley Sweeten hsweeten at visionengravers.com
Mon Oct 20 18:34:21 UTC 2014


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 <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at 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



More information about the devel mailing list