iio: health: afe4403: Use get_unaligned_be24()
This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:

committed by
Jonathan Cameron

parent
e33ff8ac6d
commit
d324ac2e93
@@ -23,6 +23,8 @@
|
|||||||
#include <linux/iio/triggered_buffer.h>
|
#include <linux/iio/triggered_buffer.h>
|
||||||
#include <linux/iio/trigger_consumer.h>
|
#include <linux/iio/trigger_consumer.h>
|
||||||
|
|
||||||
|
#include <asm/unaligned.h>
|
||||||
|
|
||||||
#include "afe440x.h"
|
#include "afe440x.h"
|
||||||
|
|
||||||
#define AFE4403_DRIVER_NAME "afe4403"
|
#define AFE4403_DRIVER_NAME "afe4403"
|
||||||
@@ -220,13 +222,11 @@ static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return 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)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
*val = (rx[0] << 16) |
|
*val = get_unaligned_be24(&rx[0]);
|
||||||
(rx[1] << 8) |
|
|
||||||
(rx[2]);
|
|
||||||
|
|
||||||
/* Disable reading from the device */
|
/* Disable reading from the device */
|
||||||
tx[3] = AFE440X_CONTROL0_WRITE;
|
tx[3] = AFE440X_CONTROL0_WRITE;
|
||||||
@@ -322,13 +322,11 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private)
|
|||||||
indio_dev->masklength) {
|
indio_dev->masklength) {
|
||||||
ret = spi_write_then_read(afe->spi,
|
ret = spi_write_then_read(afe->spi,
|
||||||
&afe4403_channel_values[bit], 1,
|
&afe4403_channel_values[bit], 1,
|
||||||
rx, 3);
|
rx, sizeof(rx));
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
buffer[i++] = (rx[0] << 16) |
|
buffer[i++] = get_unaligned_be24(&rx[0]);
|
||||||
(rx[1] << 8) |
|
|
||||||
(rx[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable reading from the device */
|
/* Disable reading from the device */
|
||||||
|
Reference in New Issue
Block a user