mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
bq27x00: Use single i2c_transfer call for property read
Doing this by using 2 calls sometimes results in unexpected values being returned on OMAP3 i2c controller. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
2ec523a823
commit
9e912f4529
@ -565,31 +565,26 @@ static DEFINE_MUTEX(battery_mutex);
|
|||||||
static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single)
|
static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = to_i2c_client(di->dev);
|
struct i2c_client *client = to_i2c_client(di->dev);
|
||||||
struct i2c_msg msg;
|
struct i2c_msg msg[2];
|
||||||
unsigned char data[2];
|
unsigned char data[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!client->adapter)
|
if (!client->adapter)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
msg.addr = client->addr;
|
msg[0].addr = client->addr;
|
||||||
msg.flags = 0;
|
msg[0].flags = 0;
|
||||||
msg.len = 1;
|
msg[0].buf = ®
|
||||||
msg.buf = data;
|
msg[0].len = sizeof(reg);
|
||||||
|
msg[1].addr = client->addr;
|
||||||
data[0] = reg;
|
msg[1].flags = I2C_M_RD;
|
||||||
ret = i2c_transfer(client->adapter, &msg, 1);
|
msg[1].buf = data;
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (single)
|
if (single)
|
||||||
msg.len = 1;
|
msg[1].len = 1;
|
||||||
else
|
else
|
||||||
msg.len = 2;
|
msg[1].len = 2;
|
||||||
|
|
||||||
msg.flags = I2C_M_RD;
|
ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
|
||||||
ret = i2c_transfer(client->adapter, &msg, 1);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user