From 7b9ebe428266fb7e0a6d769bb3ff3fcb6044b15e Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Mon, 1 Jan 2018 19:54:42 +0100 Subject: [PATCH] iio: imu: st_lsm6dsx: fix endianness in st_lsm6dsx_read_oneshot() Git-commit: 7b9ebe428266fb7e0a6d769bb3ff3fcb6044b15e Patch-mainline: v4.16-rc1 References: bsc#1051510 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) Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman Acked-by: Takashi Iwai --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -391,7 +391,7 @@ static int st_lsm6dsx_read_oneshot(struc st_lsm6dsx_sensor_disable(sensor); - *val = (s16)data; + *val = (s16)le16_to_cpu(data); return IIO_VAL_INT; }