diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-02 13:35:07 -0500 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-22 05:02:48 -0500 |
commit | 2ec523a8238a117b082ca6b0cef3b9ae812364f9 (patch) | |
tree | 8b3f51b86482c44d4d6e42a1a97d664993e25dcf /drivers/power/bq27x00_battery.c | |
parent | bf7d4140450f6dbc019a8831223e08d778f90dd7 (diff) |
bq27x00: Cleanup bq27x00_i2c_read
Some minor stylistic cleanups.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Diffstat (limited to 'drivers/power/bq27x00_battery.c')
-rw-r--r-- | drivers/power/bq27x00_battery.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index b44555f1b633..740a0ac29dd1 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c | |||
@@ -565,36 +565,39 @@ static DEFINE_MUTEX(battery_mutex); | |||
565 | static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single) | 565 | static 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[1]; | 568 | struct i2c_msg msg; |
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.addr = client->addr; |
576 | msg->flags = 0; | 576 | msg.flags = 0; |
577 | msg->len = 1; | 577 | msg.len = 1; |
578 | msg->buf = data; | 578 | msg.buf = data; |
579 | 579 | ||
580 | data[0] = reg; | 580 | data[0] = reg; |
581 | ret = i2c_transfer(client->adapter, msg, 1); | 581 | ret = i2c_transfer(client->adapter, &msg, 1); |
582 | |||
583 | if (ret < 0) | ||
584 | return ret; | ||
585 | |||
586 | if (single) | ||
587 | msg.len = 1; | ||
588 | else | ||
589 | msg.len = 2; | ||
590 | |||
591 | msg.flags = I2C_M_RD; | ||
592 | ret = i2c_transfer(client->adapter, &msg, 1); | ||
593 | if (ret < 0) | ||
594 | return ret; | ||
595 | |||
596 | if (!single) | ||
597 | ret = get_unaligned_le16(data); | ||
598 | else | ||
599 | ret = data[0]; | ||
582 | 600 | ||
583 | if (ret >= 0) { | ||
584 | if (!single) | ||
585 | msg->len = 2; | ||
586 | else | ||
587 | msg->len = 1; | ||
588 | |||
589 | msg->flags = I2C_M_RD; | ||
590 | ret = i2c_transfer(client->adapter, msg, 1); | ||
591 | if (ret >= 0) { | ||
592 | if (!single) | ||
593 | ret = get_unaligned_le16(data); | ||
594 | else | ||
595 | ret = data[0]; | ||
596 | } | ||
597 | } | ||
598 | return ret; | 601 | return ret; |
599 | } | 602 | } |
600 | 603 | ||