]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iio: magnetometer: rm3100: Use get_unaligned_be24()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 21 Apr 2020 00:31:30 +0000 (03:31 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 May 2020 08:47:20 +0000 (09:47 +0100)
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>
drivers/iio/magnetometer/rm3100-core.c

index 7c20918d81086f3e6126002b6e1f337a6780479c..43a2e420c9c40dd735424b919e739a15369e26f5 100644 (file)
@@ -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;