diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-04-21 03:31:30 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-05-03 11:47:20 +0300 |
commit | dfe3da0b2844d86d2e61d9b1fcc8a108f3fd7eb7 (patch) | |
tree | 8006ad71457b31cf15d31bc4091ffbb8171451ad | |
parent | d2fa63d2d155c366dfa9615b55ba7deb4bdb9489 (diff) | |
download | linux-dfe3da0b2844d86d2e61d9b1fcc8a108f3fd7eb7.tar.xz |
iio: magnetometer: rm3100: Use get_unaligned_be24()
This makes the driver code slightly easier to read.
Cc: Song Qiang <songqiang1304521@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | drivers/iio/magnetometer/rm3100-core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index 7c20918d8108..43a2e420c9c4 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -22,6 +22,8 @@ #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> +#include <asm/unaligned.h> + #include "rm3100.h" /* Cycle Count Registers. */ @@ -223,8 +225,7 @@ static int rm3100_read_mag(struct rm3100_data *data, int idx, int *val) goto unlock_return; mutex_unlock(&data->lock); - *val = sign_extend32((buffer[0] << 16) | (buffer[1] << 8) | buffer[2], - 23); + *val = sign_extend32(get_unaligned_be24(&buffer[0]), 23); return IIO_VAL_INT; |