Re: [PATCH v1 14/16] iio: pressure: zpa2326: Use get_unaligned_le24()

Jonathan Cameron
2020-04-25T16:50:11Z

On Tue, 21 Apr 2020 03:31:33 +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>
Include added and applied.

Thanks,

Jonathan

> ---
> drivers/iio/pressure/zpa2326.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> index 99dfe33ee402..c2ad106e3d5b 100644
> --- a/drivers/iio/pressure/zpa2326.c
> +++ b/drivers/iio/pressure/zpa2326.c
> @@ -1005,22 +1005,20 @@ static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev,
> struct regmap *regs = ((struct zpa2326_private *)
> iio_priv(indio_dev))->regmap;
> int err;
> + u8 v[3];
>
> switch (type) {
> case IIO_PRESSURE:
> zpa2326_dbg(indio_dev, "fetching raw pressure sample");
>
> - err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, value,
> - 3);
> + err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, v, sizeof(v));
> if (err) {
> zpa2326_warn(indio_dev, "failed to fetch pressure (%d)",
> err);
> return err;
> }
>
> - /* Pressure is a 24 bits wide little-endian unsigned int. */
> - *value = (((u8 *)value)[2] << 16) | (((u8 *)value)[1] << 8) |
> - ((u8 *)value)[0];
> + *value = get_unaligned_le24(&v[0]);
>
> return IIO_VAL_INT;
>