diff options
author | Grazvydas Ignotas <notasas@gmail.com> | 2011-02-15 23:27:35 +0200 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-22 11:02:48 +0100 |
commit | 9e912f452931b3da9d13d716a381ba0d5fb74ced (patch) | |
tree | f3fa488fc6e448bbe492404897227db460089c5b | |
parent | 2ec523a8238a117b082ca6b0cef3b9ae812364f9 (diff) | |
download | op-kernel-dev-9e912f452931b3da9d13d716a381ba0d5fb74ced.zip op-kernel-dev-9e912f452931b3da9d13d716a381ba0d5fb74ced.tar.gz |
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>
-rw-r--r-- | drivers/power/bq27x00_battery.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index 740a0ac..59e68db 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c @@ -565,31 +565,26 @@ static DEFINE_MUTEX(battery_mutex); 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_msg msg; + struct i2c_msg msg[2]; unsigned char data[2]; int ret; if (!client->adapter) return -ENODEV; - msg.addr = client->addr; - msg.flags = 0; - msg.len = 1; - msg.buf = data; - - data[0] = reg; - ret = i2c_transfer(client->adapter, &msg, 1); - - if (ret < 0) - return ret; - + msg[0].addr = client->addr; + msg[0].flags = 0; + msg[0].buf = ® + msg[0].len = sizeof(reg); + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = data; if (single) - msg.len = 1; + msg[1].len = 1; else - msg.len = 2; + msg[1].len = 2; - msg.flags = I2C_M_RD; - ret = i2c_transfer(client->adapter, &msg, 1); + ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); if (ret < 0) return ret; |