Skip to content

Commit

Permalink
staging:iio:ad7476: Fix off by one error for channel shift
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Sep 12, 2012
1 parent 7dd73b8 commit cb75f23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/iio/adc/ad7476_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
}, \
}

Expand Down

0 comments on commit cb75f23

Please sign in to comment.