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
181181 }
182182
183183 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);
186188 }
187189
188190 static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) {
189191 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);
192196 return ret;
193197 }
194198

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