From 6a71c56a1adac09b1a946f2543ce453d27cbccf4 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 21 Apr 2020 03:31:27 +0300 Subject: [PATCH] iio: health: afe4403: Use get_unaligned_be24() This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index dc22dc363a996..e9f87e42ff4f4 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -23,6 +23,8 @@ #include #include +#include + #include "afe440x.h" #define AFE4403_DRIVER_NAME "afe4403" @@ -220,13 +222,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, ®, 1, rx, 3); + ret = spi_write_then_read(afe->spi, ®, 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 +322,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 */ -- 2.39.5