mfd: twl-core: Add twl_i2c_read/write_u16
authorSebastian Reichel <sre@debian.org>
Sun, 16 Mar 2014 01:43:28 +0000 (02:43 +0100)
committerLee Jones <lee.jones@linaro.org>
Tue, 18 Mar 2014 08:15:34 +0000 (08:15 +0000)
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 <sre@debian.org>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Marek Belisko <marek@goldelico.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
include/linux/i2c/twl.h

index ade1c06d4cebed9c30b47ea98c69fe51df89508c..d2b16704624c6c6122a09457e00ef716ef8d0393 100644 (file)
@@ -195,6 +195,18 @@ static inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) {
        return twl_i2c_read(mod_no, val, reg, 1);
 }
 
+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);
+}
+
+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);
+       return ret;
+}
+
 int twl_get_type(void);
 int twl_get_version(void);
 int twl_get_hfclk_rate(void);