Commit cbfdc839 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Lee Jones

mfd: twl: Endian fixups in i2c write and read wrappers

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

Identified by sparse when building the IIO driver.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 11c4f2be
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment