[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1426215198-28630-1-git-send-email-andrew.smirnov@gmail.com>
Date: Thu, 12 Mar 2015 19:53:18 -0700
From: Andrey Smirnov <andrew.smirnov@...il.com>
To: linux-iio@...r.kernel.org
Cc: Andrey Smirnov <andrew.smirnov@...il.com>,
linux-kernel@...r.kernel.org, quad@...bo1ics.com
Subject: [PATCH] iio: si7020: Fix endianness for I2C reads
Si7020 outputs most significant byte of the measurement result first
and least significant byte last. As a result the data returned by
i2c_smbus_read_word_data appears as big endian. Fix this by making a
call to an approbriate byte conversion routine.
Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
---
drivers/iio/humidity/si7020.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c
index fa3b809..5c89e14 100644
--- a/drivers/iio/humidity/si7020.c
+++ b/drivers/iio/humidity/si7020.c
@@ -56,7 +56,7 @@ static int si7020_read_raw(struct iio_dev *indio_dev,
SI7020CMD_RH_HOLD);
if (ret < 0)
return ret;
- *val = ret >> 2;
+ *val = be16_to_cpu(ret) >> 2;
if (chan->type == IIO_HUMIDITYRELATIVE)
*val &= GENMASK(11, 0);
return IIO_VAL_INT;
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists