staging: comedi: addi_apci_3120: provide analog output 'readback'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 20 Oct 2014 18:34:21 +0000 (11:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Oct 2014 07:58:36 +0000 (15:58 +0800)
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@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi_apci_3120.c

index 47b1741758d19154cc53c8efd95e90f684753c4b..c093cd4bce3d661ca06f8409940fa86028c590fb 100644 (file)
@@ -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;
index abc85bf000ff27a33ba0fd66e70b8e8dd48618df..5db52cd043199aab0db8d90d30f1dd1ff3e4232d 100644 (file)
@@ -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;
        }