iio: adc: max11100: Use get_unaligned_be16() rather than opencoding.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 16 May 2021 17:25:13 +0000 (18:25 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 3 Jun 2021 17:24:13 +0000 (18:24 +0100)
The function is more explicit in showing the intent + quicker on some
platforms.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-2-jic23@kernel.org
drivers/iio/adc/max11100.c

index 6cf2175..69d607f 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <asm/unaligned.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/driver.h>
@@ -63,7 +64,7 @@ static int max11100_read_single(struct iio_dev *indio_dev, int *val)
                return -EINVAL;
        }
 
-       *val = (state->buffer[1] << 8) | state->buffer[2];
+       *val = get_unaligned_be16(&state->buffer[1]);
 
        return 0;
 }