diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-10-13 12:26:00 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-10-18 20:57:47 +0200 |
commit | d2080a87a376d5f3f1e0efbc94a8c3c7b24d0a31 (patch) | |
tree | 0c950d096fc7e776c88dcf9d3f038ec9cdf11eb8 /drivers/iio/proximity | |
parent | iio: pressure: bmp280 endian tidy ups (diff) | |
download | linux-d2080a87a376d5f3f1e0efbc94a8c3c7b24d0a31.tar.xz linux-d2080a87a376d5f3f1e0efbc94a8c3c7b24d0a31.zip |
iio: proximity: pulsedlight v2: Tidy up an endian issue
Sparse identified the following
CHECK drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16
This cleans up by adding a local variable to hold the value whilst
it is __be16 before applying endian converstion into eventual destination.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'drivers/iio/proximity')
-rw-r--r-- | drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 47af54f14756..5b369645ef49 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -136,12 +136,13 @@ static inline int lidar_write_power(struct lidar_data *data, int val) static int lidar_read_measurement(struct lidar_data *data, u16 *reg) { + __be16 value; int ret = data->xfer(data, LIDAR_REG_DATA_HBYTE | (data->i2c_enabled ? LIDAR_REG_DATA_WORD_READ : 0), - (u8 *) reg, 2); + (u8 *) &value, 2); if (!ret) - *reg = be16_to_cpu(*reg); + *reg = be16_to_cpu(value); return ret; } |