diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-02 19:35:07 +0100 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2011-02-22 11:02:48 +0100 |
commit | 2ec523a8238a117b082ca6b0cef3b9ae812364f9 (patch) | |
tree | 8b3f51b86482c44d4d6e42a1a97d664993e25dcf /drivers/power/bq27x00_battery.c | |
parent | bf7d4140450f6dbc019a8831223e08d778f90dd7 (diff) | |
download | linux-2ec523a8238a117b082ca6b0cef3b9ae812364f9.tar.gz linux-2ec523a8238a117b082ca6b0cef3b9ae812364f9.tar.bz2 linux-2ec523a8238a117b082ca6b0cef3b9ae812364f9.zip |
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); 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[1]; + struct i2c_msg msg; unsigned char data[2]; int ret; if (!client->adapter) return -ENODEV; - msg->addr = client->addr; - msg->flags = 0; - msg->len = 1; - msg->buf = data; + msg.addr = client->addr; + msg.flags = 0; + msg.len = 1; + msg.buf = data; data[0] = reg; - ret = i2c_transfer(client->adapter, msg, 1); + ret = i2c_transfer(client->adapter, &msg, 1); + + if (ret < 0) + return ret; + + if (single) + msg.len = 1; + else + msg.len = 2; + + msg.flags = I2C_M_RD; + ret = i2c_transfer(client->adapter, &msg, 1); + if (ret < 0) + return ret; + + if (!single) + ret = get_unaligned_le16(data); + else + ret = data[0]; - if (ret >= 0) { - if (!single) - msg->len = 2; - else - msg->len = 1; - - msg->flags = I2C_M_RD; - ret = i2c_transfer(client->adapter, msg, 1); - if (ret >= 0) { - if (!single) - ret = get_unaligned_le16(data); - else - ret = data[0]; - } - } return ret; } |