summaryrefslogtreecommitdiffstats
path: root/drivers/iio/pressure/hp206c.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-04-21 02:31:31 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-05-03 10:47:20 +0200
commitb3ab0adb1da98b2b6b76354b7f195ffd05abdc57 (patch)
treeccec5e854ad17ab559fa453416adbd6b4f2f0f96 /drivers/iio/pressure/hp206c.c
parentiio: magnetometer: rm3100: Use get_unaligned_be24() (diff)
downloadlinux-b3ab0adb1da98b2b6b76354b7f195ffd05abdc57.tar.xz
linux-b3ab0adb1da98b2b6b76354b7f195ffd05abdc57.zip
iio: pressure: hp206c: Use get_unaligned_be24()
This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/pressure/hp206c.c')
-rw-r--r--drivers/iio/pressure/hp206c.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c
index 3ac3632e7242..1f931f5b7a65 100644
--- a/drivers/iio/pressure/hp206c.c
+++ b/drivers/iio/pressure/hp206c.c
@@ -18,6 +18,8 @@
#include <linux/util_macros.h>
#include <linux/acpi.h>
+#include <asm/unaligned.h>
+
/* I2C commands: */
#define HP206C_CMD_SOFT_RST 0x06
@@ -93,12 +95,12 @@ static int hp206c_read_20bit(struct i2c_client *client, u8 cmd)
int ret;
u8 values[3];
- ret = i2c_smbus_read_i2c_block_data(client, cmd, 3, values);
+ ret = i2c_smbus_read_i2c_block_data(client, cmd, sizeof(values), values);
if (ret < 0)
return ret;
- if (ret != 3)
+ if (ret != sizeof(values))
return -EIO;
- return ((values[0] & 0xF) << 16) | (values[1] << 8) | (values[2]);
+ return get_unaligned_be24(&values[0]) & GENMASK(19, 0);
}
/* Spin for max 160ms until DEV_RDY is 1, or return error. */