.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * hp206c.c - HOPERF HP206C precision barometer and altimeter sensor |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
9 | 6 | * |
---|
10 | 7 | * (7-bit I2C slave address 0x76) |
---|
11 | 8 | * |
---|
.. | .. |
---|
20 | 17 | #include <linux/delay.h> |
---|
21 | 18 | #include <linux/util_macros.h> |
---|
22 | 19 | #include <linux/acpi.h> |
---|
| 20 | + |
---|
| 21 | +#include <asm/unaligned.h> |
---|
23 | 22 | |
---|
24 | 23 | /* I2C commands: */ |
---|
25 | 24 | #define HP206C_CMD_SOFT_RST 0x06 |
---|
.. | .. |
---|
96 | 95 | int ret; |
---|
97 | 96 | u8 values[3]; |
---|
98 | 97 | |
---|
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); |
---|
100 | 99 | if (ret < 0) |
---|
101 | 100 | return ret; |
---|
102 | | - if (ret != 3) |
---|
| 101 | + if (ret != sizeof(values)) |
---|
103 | 102 | return -EIO; |
---|
104 | | - return ((values[0] & 0xF) << 16) | (values[1] << 8) | (values[2]); |
---|
| 103 | + return get_unaligned_be24(&values[0]) & GENMASK(19, 0); |
---|
105 | 104 | } |
---|
106 | 105 | |
---|
107 | 106 | /* Spin for max 160ms until DEV_RDY is 1, or return error. */ |
---|
.. | .. |
---|
379 | 378 | |
---|
380 | 379 | indio_dev->info = &hp206c_info; |
---|
381 | 380 | indio_dev->name = id->name; |
---|
382 | | - indio_dev->dev.parent = &client->dev; |
---|
383 | 381 | indio_dev->modes = INDIO_DIRECT_MODE; |
---|
384 | 382 | indio_dev->channels = hp206c_channels; |
---|
385 | 383 | indio_dev->num_channels = ARRAY_SIZE(hp206c_channels); |
---|