Skip to contentSkip to conversation

iio: dac: ad5770r: Convert to get_unaligned_le16

PATCH In review Abhash Jha 2 participants 2 messages Sep 28, 2024 – Sep 29, 2024

Subsystems (2)
lore
Share & tools
lore

Abhash Jha

author
#0 lore raw

PATCH 1/1 iio: dac: ad5770r: Convert to get_unaligned_le16

Convert the manual shifting to use get_unaligned_le16 api.

---
 drivers/iio/dac/ad5770r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5770r.c +2 -1
index c360ebf52..12c98f3e6 100644
@@ -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:
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 3 lines · On Sat, 28 Sep 2024 21:48:05 +0530 Abhash Jha <[email protected]>…

Convert the manual shifting to use get_unaligned_le16 api.

Looks straight forward so I've applied this, but plenty of time for additional reviews if anyone has time to take a look.

Thanks,

Jonathan

Quoted 25 lines
---
 drivers/iio/dac/ad5770r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5770r.c +2 -1
index c360ebf52..12c98f3e6 100644
@@ -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: