staging: comedi: adv_pci1710: fix analog output readback value
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 5 Feb 2014 21:59:53 +0000 (14:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Feb 2014 17:19:30 +0000 (09:19 -0800)
commit1e85c1ea1ff2a60659e790ef8ec76c7339445841
tree51c6dd096c24edffeb9341f2a30a7cb97e379960
parent7a081ea20e043f243b6fb9d50448cbe757fbb860
staging: comedi: adv_pci1710: fix analog output readback value

The last value written to a analog output channel is cached in the
private data of this driver for readback.

Currently, the wrong value is cached in the (*insn_write) functions.
The current code stores the data[n] value for readback afer the loop
has written all the values. At this time 'n' points past the end of
the data array.

Fix the functions by using a local variable to hold the data being
written to the analog output channel. This variable is then used
after the loop is complete to store the readback value. The current
value is retrieved before the loop in case no values are actually
written..

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/adv_pci1710.c