Commit e8ee40e7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: pressure: zpa2326: Use get_unaligned_le24()

This makes the driver code slightly easier to read.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 00d5e7b2
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include <linux/iio/trigger.h> #include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h> #include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h> #include <linux/iio/triggered_buffer.h>
#include <asm/unaligned.h>
#include "zpa2326.h" #include "zpa2326.h"
/* 200 ms should be enough for the longest conversion time in one-shot mode. */ /* 200 ms should be enough for the longest conversion time in one-shot mode. */
...@@ -1005,22 +1006,20 @@ static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev, ...@@ -1005,22 +1006,20 @@ static int zpa2326_fetch_raw_sample(const struct iio_dev *indio_dev,
struct regmap *regs = ((struct zpa2326_private *) struct regmap *regs = ((struct zpa2326_private *)
iio_priv(indio_dev))->regmap; iio_priv(indio_dev))->regmap;
int err; int err;
u8 v[3];
switch (type) { switch (type) {
case IIO_PRESSURE: case IIO_PRESSURE:
zpa2326_dbg(indio_dev, "fetching raw pressure sample"); zpa2326_dbg(indio_dev, "fetching raw pressure sample");
err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, value, err = regmap_bulk_read(regs, ZPA2326_PRESS_OUT_XL_REG, v, sizeof(v));
3);
if (err) { if (err) {
zpa2326_warn(indio_dev, "failed to fetch pressure (%d)", zpa2326_warn(indio_dev, "failed to fetch pressure (%d)",
err); err);
return err; return err;
} }
/* Pressure is a 24 bits wide little-endian unsigned int. */ *value = get_unaligned_le24(&v[0]);
*value = (((u8 *)value)[2] << 16) | (((u8 *)value)[1] << 8) |
((u8 *)value)[0];
return IIO_VAL_INT; return IIO_VAL_INT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment