aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/common
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-04-21 03:31:35 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-05-03 09:47:21 +0100
commit3009fb9cabba471655f8d5de5090901f9775dc30 (patch)
treea3d17e0ee007080bee29c66b813923bf9dd7764d /drivers/iio/common
parentiio: temperature: max31856: Use get_unaligned_beXX() (diff)
downloadlinux-dev-3009fb9cabba471655f8d5de5090901f9775dc30.tar.xz
linux-dev-3009fb9cabba471655f8d5de5090901f9775dc30.zip
iio: st_sensors: Use get_unaligned_be24() and sign_extend32()
Use these functions instead of open-coding them. Cc: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index a0c2cbd60c6f..bd82da3a504d 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -20,11 +20,6 @@
#include "st_sensors_core.h"
-static inline u32 st_sensors_get_unaligned_le24(const u8 *p)
-{
- return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8;
-}
-
int st_sensors_write_data_with_mask(struct iio_dev *indio_dev,
u8 reg_addr, u8 mask, u8 data)
{
@@ -543,7 +538,7 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
else if (byte_for_channel == 2)
*data = (s16)get_unaligned_le16(outdata);
else if (byte_for_channel == 3)
- *data = (s32)st_sensors_get_unaligned_le24(outdata);
+ *data = (s32)sign_extend32(get_unaligned_le24(outdata), 23);
st_sensors_free_memory:
kfree(outdata);