Skip to contentSkip to conversation

iio: adc: max1363: Convert to get_unaligned_be16

PATCH Applied Abhash Jha 2 participants 2 messages Sep 20, 2024 – Sep 28, 2024 IIO

lore
Share & tools
lore

Abhash Jha

author
#0 lore raw

PATCH 1/1 iio: adc: max1363: Convert to get_unaligned_be16

Converted manual shifting and or to use get_unaligned_be16 api instead.

---
 drivers/iio/adc/max1363.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/max1363.c +3 -1
index bf4b6dc53..0801317da 100644
@@ -33,6 +33,8 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
+#include <asm/unaligned.h>
+
 #define MAX1363_SETUP_BYTE(a) ((a) | 0x80)
 
 /* There is a fair bit more defined here than currently
@@ -391,7 +393,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev,
 			if (data < 0)
 				return data;
 
-			data = (rxbuf[1] | rxbuf[0] << 8) &
+			data = get_unaligned_be16(rxbuf) &
 				((1 << st->chip_info->bits) - 1);
 		} else {
 			/* Get reading */
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 4 lines · On Fri, 20 Sep 2024 23:44:37 +0530 Abhash Jha <[email protected]>…

Converted manual shifting and or to use get_unaligned_be16 api instead.

Applied

Thanks,

Jonathan

Quoted 26 lines
---
 drivers/iio/adc/max1363.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/max1363.c +3 -1
index bf4b6dc53..0801317da 100644
@@ -33,6 +33,8 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
+#include <asm/unaligned.h>
+
 #define MAX1363_SETUP_BYTE(a) ((a) | 0x80)
 
 /* There is a fair bit more defined here than currently
@@ -391,7 +393,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev,
 			if (data < 0)
 				return data;
 
-			data = (rxbuf[1] | rxbuf[0] << 8) &
+			data = get_unaligned_be16(rxbuf) &
 				((1 << st->chip_info->bits) - 1);
 		} else {
 			/* Get reading */