aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2011-02-15 16:27:35 -0500
committerLars-Peter Clausen <lars@metafoo.de>2011-02-22 05:02:48 -0500
commit9e912f452931b3da9d13d716a381ba0d5fb74ced (patch)
treef3fa488fc6e448bbe492404897227db460089c5b /drivers/power
parent2ec523a8238a117b082ca6b0cef3b9ae812364f9 (diff)
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>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq27x00_battery.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 740a0ac29dd1..59e68dbd028b 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -565,31 +565,26 @@ static DEFINE_MUTEX(battery_mutex);
565static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single) 565static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single)
566{ 566{
567 struct i2c_client *client = to_i2c_client(di->dev); 567 struct i2c_client *client = to_i2c_client(di->dev);
568 struct i2c_msg msg; 568 struct i2c_msg msg[2];
569 unsigned char data[2]; 569 unsigned char data[2];
570 int ret; 570 int ret;
571 571
572 if (!client->adapter) 572 if (!client->adapter)
573 return -ENODEV; 573 return -ENODEV;
574 574
575 msg.addr = client->addr; 575 msg[0].addr = client->addr;
576 msg.flags = 0; 576 msg[0].flags = 0;
577 msg.len = 1; 577 msg[0].buf = &reg;
578 msg.buf = data; 578 msg[0].len = sizeof(reg);
579 579 msg[1].addr = client->addr;
580 data[0] = reg; 580 msg[1].flags = I2C_M_RD;
581 ret = i2c_transfer(client->adapter, &msg, 1); 581 msg[1].buf = data;
582
583 if (ret < 0)
584 return ret;
585
586 if (single) 582 if (single)
587 msg.len = 1; 583 msg[1].len = 1;
588 else 584 else
589 msg.len = 2; 585 msg[1].len = 2;
590 586
591 msg.flags = I2C_M_RD; 587 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
592 ret = i2c_transfer(client->adapter, &msg, 1);
593 if (ret < 0) 588 if (ret < 0)
594 return ret; 589 return ret;
595 590