diff mbox series

[v1,10/16] iio: light: zopt2201: Use get_unaligned_le24()

Message ID 20200421003135.23060-10-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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/light/zopt2201.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

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

> This makes the driver code slightly easier to read.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied with asm/unaligned.h include added.

J
> ---
>  drivers/iio/light/zopt2201.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/zopt2201.c b/drivers/iio/light/zopt2201.c
> index 5f54f39e7a4c..0df45b42c091 100644
> --- a/drivers/iio/light/zopt2201.c
> +++ b/drivers/iio/light/zopt2201.c
> @@ -219,7 +219,7 @@ static int zopt2201_read(struct zopt2201_data *data, u8 reg)
>  		goto fail;
>  	mutex_unlock(&data->lock);
>  
> -	return (buf[2] << 16) | (buf[1] << 8) | buf[0];
> +	return get_unaligned_le24(&buf[0]);
>  
>  fail:
>  	mutex_unlock(&data->lock);
diff mbox series

Patch

diff --git a/drivers/iio/light/zopt2201.c b/drivers/iio/light/zopt2201.c
index 5f54f39e7a4c..0df45b42c091 100644
--- a/drivers/iio/light/zopt2201.c
+++ b/drivers/iio/light/zopt2201.c
@@ -219,7 +219,7 @@  static int zopt2201_read(struct zopt2201_data *data, u8 reg)
 		goto fail;
 	mutex_unlock(&data->lock);
 
-	return (buf[2] << 16) | (buf[1] << 8) | buf[0];
+	return get_unaligned_le24(&buf[0]);
 
 fail:
 	mutex_unlock(&data->lock);