summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-09-10 09:34:00 +0100
committerJonathan Cameron <jic23@kernel.org>2012-09-12 18:32:07 +0100
commitcb75f2335c4068414e4b48aea38a3351bd6785a0 (patch)
tree9b6ae0802c62ff2c9e12fde4b76cd082b4b4107c /drivers
parent7dd73b866ed656b4ef7b475de4588cb1a3f765d4 (diff)
staging:iio:ad7476: Fix off by one error for channel shift
The datasheet is a bit confusing about this. It says that a dataword has 4 leading zeros, but the first zero is already put on the bus when CS is pulled low and the second zero is put on the bus on the first leading edge of SCLK, so when the first bit is sampled on the first trailing edge it will sample what the datasheet refers to as the second leading zero. Subsequently we only see 3 leading zeros in the 16 bit dataword and the result we get is shifted to the left by one bit. Fix this by adjusting the channel shift by 1. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/iio/adc/ad7476_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index 4f6d59e89fcd..33435ed6caa5 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -76,7 +76,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
.sign = 'u', \
.realbits = bits, \
.storagebits = 16, \
- .shift = 12 - bits, \
+ .shift = 13 - bits, \
}, \
}