From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org, drivers@analog.com,
Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH v2 01/10] staging:iio:ad7476: Fix off by one error for channel shift
Date: Mon, 10 Sep 2012 10:34:32 +0200 [thread overview]
Message-ID: <1347266081-6045-1-git-send-email-lars@metafoo.de> (raw)
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>
---
drivers/staging/iio/adc/ad7476_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index 4f6d59e..33435ed 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, \
}, \
}
--
1.7.10.4
next reply other threads:[~2012-09-10 8:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 8:34 Lars-Peter Clausen [this message]
2012-09-10 8:34 ` [PATCH v2 02/10] staging:iio:ad7476: Remove duplicated chip info entries Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 03/10] staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 04/10] staging:iio:ad7476: Rework reference voltage handling Lars-Peter Clausen
2012-09-13 19:59 ` Jonathan Cameron
2012-09-14 8:51 ` Lars-Peter Clausen
2012-09-14 9:51 ` Jonathan Cameron
2012-09-10 8:34 ` [PATCH v2 05/10] staging:iio:ad7476: Squash driver into a single file Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 06/10] staging:iio:ad7476: Use be16_to_cpup instead of open-coding it Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 07/10] iio: Move ad7476 driver out of staging Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 08/10] iio:ad7476: Add ad7910/ad7920 device table entries Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 09/10] iio:ad7476: Add ad7940 support Lars-Peter Clausen
2012-09-10 8:34 ` [PATCH v2 10/10] iio:ad7476: Add support for ad7274/ad7275/ad7276/ad7277/ad7278 Lars-Peter Clausen
2012-09-10 9:24 ` [PATCH v3 10/10] iio:ad7476: Add support for ad7273/ad7274/ad7276/ad7277/ad7278 Lars-Peter Clausen
2012-09-10 9:33 ` [PATCH v4 " Lars-Peter Clausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347266081-6045-1-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=drivers@analog.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).