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)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 1 Apr 2014 23:58:50 +0000 (00:58 +0100)
commit78f94be0386e7b4d2a871950038b66242ff662db
tree711546cffdc77db252e32b1a9e474fe272cf694b
parent7fd7398a897d649086c8f86626ed1d082413a6a0
staging: comedi: adv_pci1710: fix analog output readback value

commit 1e85c1ea1ff2a60659e790ef8ec76c7339445841 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/staging/comedi/drivers/adv_pci1710.c