Skip to content

Commit

Permalink
iio: magnetometer: rm3100: Use get_unaligned_be24()
Browse files Browse the repository at this point in the history
This makes the driver code slightly easier to read.

Cc: Song Qiang <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
andy-shev authored and jic23 committed May 3, 2020
1 parent d2fa63d commit dfe3da0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/iio/magnetometer/rm3100-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit dfe3da0

Please sign in to comment.