Skip to contentSkip to conversation

mfd: twl: endian fixups in i2c write and read wrappers.

PATCH Applied [email protected] 2 participants 2 messages Oct 13, 2019 – Oct 16, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 mfd: twl: endian fixups in i2c write and read wrappers.

From: Jonathan Cameron <[email protected]>

Use a local variable to ensure correct endian types for intermediate results.

Identified by sparse when building the IIO driver.

---
 include/linux/mfd/twl.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
include/linux/mfd/twl.h +8 -4
index 44aff52a5002..089e8942223a 100644
@@ -181,14 +181,18 @@ static inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) {
 }
 
 static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) {
-	val = cpu_to_le16(val);
-	return twl_i2c_write(mod_no, (u8*) &val, reg, 2);
+	__le16 value;
+
+	value = cpu_to_le16(val);
+	return twl_i2c_write(mod_no, (u8 *) &value, reg, 2);
 }
 
 static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) {
 	int ret;
-	ret = twl_i2c_read(mod_no, (u8*) val, reg, 2);
-	*val = le16_to_cpu(*val);
+	__le16 value;
+
+	ret = twl_i2c_read(mod_no, (u8 *) &value, reg, 2);
+	*val = le16_to_cpu(value);
 	return ret;
 }
 
Signature · 1 line
2.23.0
Applied
#1 lore raw
Quoted 5 lines · On Sun, 13 Oct 2019, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Use a local variable to ensure correct endian types for intermediate results.

Quoted 7 lines

Identified by sparse when building the IIO driver.

---
 include/linux/mfd/twl.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog