提交 4fcc084e 编写于 作者: P Pali Rohár 提交者: Lokesh Vutla

power: twl4030: Add twl4030_i2c_read() function

Function twl4030_i2c_read() is like twl4030_i2c_read_u8() but instead of
single value it rather returns array of values.
Signed-off-by: NPali Rohár <pali@kernel.org>
Reviewed-by: NJaehoon Chung <jh80.chung@samsung.com>
上级 a1337e35
......@@ -201,7 +201,7 @@ int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
return 0;
}
int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *valp, int len)
{
struct udevice *dev;
int ret;
......@@ -211,12 +211,11 @@ int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *valp)
pr_err("unable to get I2C bus. ret %d\n", ret);
return ret;
}
ret = dm_i2c_reg_read(dev, reg);
if (ret < 0) {
ret = dm_i2c_read(dev, reg, valp, len);
if (ret) {
pr_err("reading from twl4030 failed. ret %d\n", ret);
return ret;
}
*valp = (u8)ret;
return 0;
}
#endif
......@@ -654,14 +654,20 @@ static inline int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
return i2c_write(chip_no, reg, 1, &val, 1);
}
static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
static inline int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *val, int len)
{
return i2c_read(chip_no, reg, 1, val, 1);
return i2c_read(chip_no, reg, 1, val, len);
}
#else
int twl4030_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
int twl4030_i2c_read(u8 chip_no, u8 reg, u8 *val, int len);
#endif
static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
{
return twl4030_i2c_read(chip_no, reg, val, 1);
}
/*
* Power
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册