Skip to contentSkip to conversation

iio: imu: st_lsm6dsx: fix endianness in st_lsm6dsx_read_oneshot()

PATCH Applied Lorenzo Bianconi 2 participants 2 messages Jan 1, 2018 – Jan 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 iio: imu: st_lsm6dsx: fix endianness in st_lsm6dsx_read_oneshot()

Apply le16_to_cpu() to data read from the sensor in order to take into account architecture endianness

Fixes 290a6ce11d93 (iio: imu: add support to lsm6dsx driver)
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
index 239c735242be..812cd25f284e 100644
@@ -448,7 +448,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
 
 	st_lsm6dsx_sensor_disable(sensor);
 
-	*val = (s16)data;
+	*val = (s16)le16_to_cpu(data);
 
 	return IIO_VAL_INT;
 }
Signature · 1 line
2.15.1
maintainer
#1 lore raw
Quoted 5 lines · On Mon, 1 Jan 2018 19:54:42 +0100 Lorenzo Bianconi…

Apply le16_to_cpu() to data read from the sensor in order to take into account architecture endianness

Fixes 290a6ce11d93 (iio: imu: add support to lsm6dsx driver)

I'm going to take this via togreg rather than the fixes branch purely because we are very late in the cycle so that is probably quicker now!

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
index 239c735242be..812cd25f284e 100644
@@ -448,7 +448,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor,
 
 	st_lsm6dsx_sensor_disable(sensor);
 
-	*val = (s16)data;
+	*val = (s16)le16_to_cpu(data);
 
 	return IIO_VAL_INT;
 }