lkml.org 
[lkml]   [2011]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 13/14] POWER: bq27x00: Cleanup bq27x00_i2c_read
    Date
    Some minor stylistic cleanups.

    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    ---
    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 83904a2..03d073c 100644
    --- a/drivers/power/bq27x00_battery.c
    +++ b/drivers/power/bq27x00_battery.c
    @@ -558,36 +558,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 err, 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;
    - err = i2c_transfer(client->adapter, msg, 1);
    + err = i2c_transfer(client->adapter, &msg, 1);
    +
    + if (err < 0)
    + return err;
    +
    + if (single)
    + msg.len = 1;
    + else
    + msg.len = 2;
    +
    + msg.flags = I2C_M_RD;
    + err = i2c_transfer(client->adapter, &msg, 1);
    + if (err < 0)
    + return err;
    +
    + if (!single)
    + ret = get_unaligned_le16(data);
    + else
    + ret = data[0];

    - if (err >= 0) {
    - if (!single)
    - msg->len = 2;
    - else
    - msg->len = 1;
    -
    - msg->flags = I2C_M_RD;
    - err = i2c_transfer(client->adapter, msg, 1);
    - if (err >= 0) {
    - if (!single)
    - ret = get_unaligned_le16(data);
    - else
    - ret = data[0];
    - }
    - }
    return ret;
    }

    --
    1.7.2.3


    \
     
     \ /
      Last update: 2011-02-06 20:37    [W:0.024 / U:29.724 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site