Skip to content

Commit 204dfd6

Browse files
sreLee Jones
authored andcommitted
mfd: twl-core: Add twl_i2c_read/write_u16
Add a simple twl_i2c_read/write_u16 wrapper over the twl_i2c_read/write, which is similar to the twl_i2c_read/write_u8 wrapper. Signed-off-by: Sebastian Reichel <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Tested-by: Marek Belisko <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 99be024 commit 204dfd6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/i2c/twl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ static inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) {
195195
return twl_i2c_read(mod_no, val, reg, 1);
196196
}
197197

198+
static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) {
199+
val = cpu_to_le16(val);
200+
return twl_i2c_write(mod_no, (u8*) &val, reg, 2);
201+
}
202+
203+
static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) {
204+
int ret;
205+
ret = twl_i2c_read(mod_no, (u8*) val, reg, 2);
206+
*val = le16_to_cpu(*val);
207+
return ret;
208+
}
209+
198210
int twl_get_type(void);
199211
int twl_get_version(void);
200212
int twl_get_hfclk_rate(void);

0 commit comments

Comments
 (0)