diff mbox series

[v1,08/16] iio: health: afe4403: Use get_unaligned_be24()

Message ID 20200421003135.23060-8-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/health/afe4403.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jonathan Cameron April 25, 2020, 4:41 p.m. UTC | #1
On Tue, 21 Apr 2020 03:31:27 +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 header include added.

J
> ---
>  drivers/iio/health/afe4403.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
> index dc22dc363a99..db44b53e9330 100644
> --- a/drivers/iio/health/afe4403.c
> +++ b/drivers/iio/health/afe4403.c
> @@ -220,13 +220,11 @@ static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val)
>  	if (ret)
>  		return ret;
>  
> -	ret = spi_write_then_read(afe->spi, &reg, 1, rx, 3);
> +	ret = spi_write_then_read(afe->spi, &reg, 1, rx, sizeof(rx));
>  	if (ret)
>  		return ret;
>  
> -	*val = (rx[0] << 16) |
> -		(rx[1] << 8) |
> -		(rx[2]);
> +	*val = get_unaligned_be24(&rx[0]);
>  
>  	/* Disable reading from the device */
>  	tx[3] = AFE440X_CONTROL0_WRITE;
> @@ -322,13 +320,11 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
>  			 indio_dev->masklength) {
>  		ret = spi_write_then_read(afe->spi,
>  					  &afe4403_channel_values[bit], 1,
> -					  rx, 3);
> +					  rx, sizeof(rx));
>  		if (ret)
>  			goto err;
>  
> -		buffer[i++] = (rx[0] << 16) |
> -				(rx[1] << 8) |
> -				(rx[2]);
> +		buffer[i++] = get_unaligned_be24(&rx[0]);
>  	}
>  
>  	/* Disable reading from the device */
diff mbox series

Patch

diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index dc22dc363a99..db44b53e9330 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -220,13 +220,11 @@  static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val)
 	if (ret)
 		return ret;
 
-	ret = spi_write_then_read(afe->spi, &reg, 1, rx, 3);
+	ret = spi_write_then_read(afe->spi, &reg, 1, rx, sizeof(rx));
 	if (ret)
 		return ret;
 
-	*val = (rx[0] << 16) |
-		(rx[1] << 8) |
-		(rx[2]);
+	*val = get_unaligned_be24(&rx[0]);
 
 	/* Disable reading from the device */
 	tx[3] = AFE440X_CONTROL0_WRITE;
@@ -322,13 +320,11 @@  static irqreturn_t afe4403_trigger_handler(int irq, void *private)
 			 indio_dev->masklength) {
 		ret = spi_write_then_read(afe->spi,
 					  &afe4403_channel_values[bit], 1,
-					  rx, 3);
+					  rx, sizeof(rx));
 		if (ret)
 			goto err;
 
-		buffer[i++] = (rx[0] << 16) |
-				(rx[1] << 8) |
-				(rx[2]);
+		buffer[i++] = get_unaligned_be24(&rx[0]);
 	}
 
 	/* Disable reading from the device */