linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Galbusera <gizero@gmail.com>
To: jic23@kernel.org
Cc: linux-iio@vger.kernel.org, Andrea Galbusera <gizero@gmail.com>
Subject: [PATCH 1/4] iio: adc: mcp320x: add masking of unknown bits
Date: Tue, 14 Jul 2015 15:36:20 +0200	[thread overview]
Message-ID: <1436880983-29017-1-git-send-email-gizero@gmail.com> (raw)

According to the datasheet, the 2 MSBs for parts 3001 and 3201 are
unspecified and should be masked out

Signed-off-by: Andrea Galbusera <gizero@gmail.com>
---

This was already suggested but for some reason got lost during review of a
previous patch. See http://marc.info/?l=linux-iio&m=140748835509583&w=2
and following discussion

 drivers/iio/adc/mcp320x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
index 8d9c9b9..0673ee7 100644
--- a/drivers/iio/adc/mcp320x.c
+++ b/drivers/iio/adc/mcp320x.c
@@ -114,13 +114,13 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel,
 
 	switch (device_index) {
 	case mcp3001:
-		return (adc->rx_buf[0] << 5 | adc->rx_buf[1] >> 3);
+		return ((adc->rx_buf[0] & 0x1f) << 5 | adc->rx_buf[1] >> 3);
 	case mcp3002:
 	case mcp3004:
 	case mcp3008:
 		return (adc->rx_buf[0] << 2 | adc->rx_buf[1] >> 6);
 	case mcp3201:
-		return (adc->rx_buf[0] << 7 | adc->rx_buf[1] >> 1);
+		return ((adc->rx_buf[0] & 0x1f) << 7 | adc->rx_buf[1] >> 1);
 	case mcp3202:
 	case mcp3204:
 	case mcp3208:
-- 
1.9.1

             reply	other threads:[~2015-07-14 13:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14 13:36 Andrea Galbusera [this message]
2015-07-14 13:36 ` [PATCH 2/4] iio: adc: mcp320x: Add support for mcp3301 Andrea Galbusera
2015-07-14 13:36 ` [PATCH 3/4] iio: adc: mcp320x: Kconfig update description Andrea Galbusera
2015-07-14 21:01   ` Jonathan Cameron
2015-07-14 13:36 ` [PATCH 4/4] iio: adc: mcp320x: update dt-bindings help Andrea Galbusera
2015-07-14 21:02   ` Jonathan Cameron
2015-07-19 12:39     ` Jonathan Cameron
2015-07-14 21:04 ` [PATCH 1/4] iio: adc: mcp320x: add masking of unknown bits Jonathan Cameron
2015-07-15  5:07   ` Andrea Galbusera
2015-07-15  5:13   ` Andrea Galbusera
2015-07-15 18:12 ` Hartmut Knaack
2015-07-19 12:33   ` Jonathan Cameron
2015-07-22  5:15     ` Andrea Galbusera
2015-07-22  5:57       ` Jonathan Cameron

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=1436880983-29017-1-git-send-email-gizero@gmail.com \
    --to=gizero@gmail.com \
    --cc=jic23@kernel.org \
    --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).