diff mbox series

[v1,11/16] iio: magnetometer: rm3100: Use get_unaligned_be24()

Message ID 20200421003135.23060-11-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,01/16] iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24() | expand

Commit Message

Andy Shevchenko April 21, 2020, 12:31 a.m. UTC
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>
---
 drivers/iio/magnetometer/rm3100-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jonathan Cameron April 25, 2020, 4:44 p.m. UTC | #1
On Tue, 21 Apr 2020 03:31:30 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> 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>
Header and typo (see below fixed)

Applied to the togreg branch of iio.git and pushed out as testing
to see what else we missed :(

> ---
>  drivers/iio/magnetometer/rm3100-core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c
> index 7c20918d8108..b3ae9a6c439b 100644
> --- a/drivers/iio/magnetometer/rm3100-core.c
> +++ b/drivers/iio/magnetometer/rm3100-core.c
> @@ -223,8 +223,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_unalinged_be24(&buffer[0]), 23);

unaligned

>  
>  	return IIO_VAL_INT;
>
diff mbox series

Patch

diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c
index 7c20918d8108..b3ae9a6c439b 100644
--- a/drivers/iio/magnetometer/rm3100-core.c
+++ b/drivers/iio/magnetometer/rm3100-core.c
@@ -223,8 +223,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_unalinged_be24(&buffer[0]), 23);
 
 	return IIO_VAL_INT;