hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/iio/pressure/hp206c.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * hp206c.c - HOPERF HP206C precision barometer and altimeter sensor
34 *
45 * Copyright (c) 2016, Intel Corporation.
5
- *
6
- * This file is subject to the terms and conditions of version 2 of
7
- * the GNU General Public License. See the file COPYING in the main
8
- * directory of this archive for more details.
96 *
107 * (7-bit I2C slave address 0x76)
118 *
....@@ -20,6 +17,8 @@
2017 #include <linux/delay.h>
2118 #include <linux/util_macros.h>
2219 #include <linux/acpi.h>
20
+
21
+#include <asm/unaligned.h>
2322
2423 /* I2C commands: */
2524 #define HP206C_CMD_SOFT_RST 0x06
....@@ -96,12 +95,12 @@
9695 int ret;
9796 u8 values[3];
9897
99
- ret = i2c_smbus_read_i2c_block_data(client, cmd, 3, values);
98
+ ret = i2c_smbus_read_i2c_block_data(client, cmd, sizeof(values), values);
10099 if (ret < 0)
101100 return ret;
102
- if (ret != 3)
101
+ if (ret != sizeof(values))
103102 return -EIO;
104
- return ((values[0] & 0xF) << 16) | (values[1] << 8) | (values[2]);
103
+ return get_unaligned_be24(&values[0]) & GENMASK(19, 0);
105104 }
106105
107106 /* Spin for max 160ms until DEV_RDY is 1, or return error. */
....@@ -379,7 +378,6 @@
379378
380379 indio_dev->info = &hp206c_info;
381380 indio_dev->name = id->name;
382
- indio_dev->dev.parent = &client->dev;
383381 indio_dev->modes = INDIO_DIRECT_MODE;
384382 indio_dev->channels = hp206c_channels;
385383 indio_dev->num_channels = ARRAY_SIZE(hp206c_channels);