summaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2022-06-26 13:29:24 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-08-15 22:30:00 +0100
commitebf30bed140d1da42331ce2e90125fb5e3cc5191 (patch)
treec15fd81816f13a6392e7b7e7a0d6258a2511f446 /drivers/staging
parent1efc41035f1841acf0af2bab153158e27ce94f10 (diff)
downloadlinux-ebf30bed140d1da42331ce2e90125fb5e3cc5191.tar.bz2
staging: iio: cdc: ad7746: Use explicit be24 handling.
Chance from fiddly local implementation of be24 to cpu endian conversion by reading into a 3 byte buffer and using get_unaligned_be24() Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220626122938.582107-4-jic23@kernel.org
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/iio/cdc/ad7746.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 52b8957c19c9..08f73be5797a 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -15,6 +15,8 @@
#include <linux/stat.h>
#include <linux/sysfs.h>
+#include <asm/unaligned.h>
+
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -95,10 +97,7 @@ struct ad7746_chip_info {
u8 capdac[2][2];
s8 capdac_set;
- union {
- __be32 d32;
- u8 d8[4];
- } data ____cacheline_aligned;
+ u8 data[3] ____cacheline_aligned;
};
enum ad7746_chan {
@@ -546,13 +545,14 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
/* Now read the actual register */
ret = i2c_smbus_read_i2c_block_data(chip->client,
- chan->address >> 8, 3,
- &chip->data.d8[1]);
+ chan->address >> 8,
+ sizeof(chip->data),
+ chip->data);
if (ret < 0)
goto out;
- *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000;
+ *val = get_unaligned_be24(chip->data) - 0x800000;
switch (chan->type) {
case IIO_TEMP: