iio: dac: ad5686: fix bit shift read register
authorMircea Caprioru <mircea.caprioru@analog.com>
Thu, 6 Dec 2018 13:53:15 +0000 (15:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Jan 2019 08:51:08 +0000 (09:51 +0100)
commitaf7cc8ebab4aade6b2a1860b31bbdda3c9739ecc
tree15073f3f781ac48751c158cd6ba81a9e4513200e
parenta854ab8f6446c551fb0f318931cabc9bb9a81c63
iio: dac: ad5686: fix bit shift read register

commit 0e76df5c978338f3051e5126fc0c4245c57a307a upstream.

This patch solves the register readback issue with the bit shift. When the
dac resolution was lower than the register size (ex. 12 bits out of 16
bits) the readback value was not shifted with the difference in bits and
the value was higher. Also a mask is applied on the read value in order to
get the value relative to the actual bit size.

Fixes: 0357e488b8 ("iio:dac:ad5686: Refactor the driver")
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/dac/ad5686.c