Skip to contentSkip to conversation

iio: adc: mt6360-adc: Converted to use get_unaligned_be16()

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: adc: mt6360-adc: Converted to use get_unaligned_be16()

Changed the manual shifting and adding of bytes to use get_unaligned_be16() api instead.

---
 drivers/iio/adc/mt6360-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/mt6360-adc.c +1 -1
index 3710473e5..91befe2cd 100644
@@ -124,7 +124,7 @@ static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int
 		usleep_range(ADC_LOOP_TIME_US / 2, ADC_LOOP_TIME_US);
 	}
 
-	*val = rpt[1] << 8 | rpt[2];
+	*val = get_unaligned_be16(&rpt[1]);
 	ret = IIO_VAL_INT;
 
 out_adc_conv:
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 4 lines · On Sat, 28 Sep 2024 21:41:08 +0530 Abhash Jha <[email protected]>…

Changed the manual shifting and adding of bytes to use get_unaligned_be16() api instead.

Looks simple so I've applied it, but plenty of time for additional reviews to come in.

Jonathan

Quoted 17 lines
---
 drivers/iio/adc/mt6360-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/mt6360-adc.c +1 -1
index 3710473e5..91befe2cd 100644
@@ -124,7 +124,7 @@ static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int
 		usleep_range(ADC_LOOP_TIME_US / 2, ADC_LOOP_TIME_US);
 	}
 
-	*val = rpt[1] << 8 | rpt[2];
+	*val = get_unaligned_be16(&rpt[1]);
 	ret = IIO_VAL_INT;
 
 out_adc_conv: