From b38d64946f8e78055f742f23678b5ebed674a5b3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:25 -0700 Subject: [PATCH] staging: comedi: addi_apci_3xxx: 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/addi_apci_3xxx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 0f0c7fa5daa3..1f59f1681831 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -628,16 +628,20 @@ static int apci3xxx_ao_insn_write(struct comedi_device *dev, int i; for (i = 0; i < insn->n; i++) { + unsigned int val = data[i]; + /* Set the range selection */ writel(range, dev->mmio + 96); /* Write the analog value to the selected channel */ - writel((data[i] << 8) | chan, dev->mmio + 100); + writel((val << 8) | chan, dev->mmio + 100); /* Wait the end of transfer */ ret = comedi_timeout(dev, s, insn, apci3xxx_ao_eoc, 0); if (ret) return ret; + + s->readback[chan] = val; } return insn->n; @@ -850,6 +854,11 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, s->maxdata = 0x0fff; s->range_table = &apci3xxx_ao_range; s->insn_write = apci3xxx_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; subdev++; } -- 2.11.0