Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Jonathan Cameron and committed by
Lee Jones
cbfdc839 11c4f2be

+8 -4
+8 -4
include/linux/mfd/twl.h
··· 181 181 } 182 182 183 183 static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) { 184 - val = cpu_to_le16(val); 185 - return twl_i2c_write(mod_no, (u8*) &val, reg, 2); 184 + __le16 value; 185 + 186 + value = cpu_to_le16(val); 187 + return twl_i2c_write(mod_no, (u8 *) &value, reg, 2); 186 188 } 187 189 188 190 static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) { 189 191 int ret; 190 - ret = twl_i2c_read(mod_no, (u8*) val, reg, 2); 191 - *val = le16_to_cpu(*val); 192 + __le16 value; 193 + 194 + ret = twl_i2c_read(mod_no, (u8 *) &value, reg, 2); 195 + *val = le16_to_cpu(value); 192 196 return ret; 193 197 } 194 198