iio: dac: ad5770r: Convert to get_unaligned_le16
authorAbhash Jha <abhashkumarjha123@gmail.com>
Sat, 28 Sep 2024 16:18:05 +0000 (21:48 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 5 Oct 2024 11:09:15 +0000 (12:09 +0100)
Convert the manual shifting to use `get_unaligned_le16` api.

Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
Link: https://patch.msgid.link/20240928161805.165543-1-abhashkumarjha123@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ad5770r.c

index c360ebf5297ab9461e25ae831af2c291346c66aa..12c98f3e62a545d8429387618097dcae3fc37114 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <asm/unaligned.h>
 
 #define ADI_SPI_IF_CONFIG_A            0x00
 #define ADI_SPI_IF_CONFIG_B            0x01
@@ -325,7 +326,7 @@ static int ad5770r_read_raw(struct iio_dev *indio_dev,
                if (ret)
                        return 0;
 
-               buf16 = st->transf_buf[0] + (st->transf_buf[1] << 8);
+               buf16 = get_unaligned_le16(st->transf_buf);
                *val = buf16 >> 2;
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE: