History

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.

Jonathan Cameron committed 7 years ago

Commit cbfdc831 parent 11c4f2b1 file · +8 −4Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t