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 <[email protected]>
---
 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to