Skip to content

Commit 0d2f6fd

Browse files
ChrisLesiakjic23
authored andcommitted
iio: si7020: Swap data byte order
The Silicon Labs Si7013, Si7020, and Si7021 family of I2C humidity and temperature sensors deliver 16 bit data high byte first. See the datasheet available at: https://www.silabs.com/Support%20Documents%2fTechnicalDocs%2fSi7020-A20.pdf But as documented in Documentation/i2c/smbus-protocol, i2c_smbus_read_word_data() expects the low byte first. Change the driver to use i2c_smbus_read_word_swapped to get correct byte order. Signed-off-by: Chris Lesiak <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 8546d2e commit 0d2f6fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/iio/humidity/si7020.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ static int si7020_read_raw(struct iio_dev *indio_dev,
5050

5151
switch (mask) {
5252
case IIO_CHAN_INFO_RAW:
53-
ret = i2c_smbus_read_word_data(*client,
54-
chan->type == IIO_TEMP ?
55-
SI7020CMD_TEMP_HOLD :
56-
SI7020CMD_RH_HOLD);
53+
ret = i2c_smbus_read_word_swapped(*client,
54+
chan->type == IIO_TEMP ?
55+
SI7020CMD_TEMP_HOLD :
56+
SI7020CMD_RH_HOLD);
5757
if (ret < 0)
5858
return ret;
5959
*val = ret >> 2;

0 commit comments

Comments
 (0)