mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 07:30:16 +00:00
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>
This commit is contained in:
parent
bf7d414045
commit
2ec523a823
@ -565,36 +565,39 @@ static DEFINE_MUTEX(battery_mutex);
|
|||||||
static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single)
|
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_client *client = to_i2c_client(di->dev);
|
||||||
struct i2c_msg msg[1];
|
struct i2c_msg msg;
|
||||||
unsigned char data[2];
|
unsigned char data[2];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!client->adapter)
|
if (!client->adapter)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
msg->addr = client->addr;
|
msg.addr = client->addr;
|
||||||
msg->flags = 0;
|
msg.flags = 0;
|
||||||
msg->len = 1;
|
msg.len = 1;
|
||||||
msg->buf = data;
|
msg.buf = data;
|
||||||
|
|
||||||
data[0] = reg;
|
data[0] = reg;
|
||||||
ret = i2c_transfer(client->adapter, msg, 1);
|
ret = i2c_transfer(client->adapter, &msg, 1);
|
||||||
|
|
||||||
if (ret >= 0) {
|
if (ret < 0)
|
||||||
if (!single)
|
return ret;
|
||||||
msg->len = 2;
|
|
||||||
else
|
if (single)
|
||||||
msg->len = 1;
|
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];
|
||||||
|
|
||||||
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user