Commit 265fec2a authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: smbus: don't abuse loop variable

Don't use 'i' to carry data, make a specific variable for it. After the
move to memcpy recently, we can even remove 'i'.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 3928bbb0
...@@ -324,7 +324,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, ...@@ -324,7 +324,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
int num = read_write == I2C_SMBUS_READ ? 2 : 1; int num = read_write == I2C_SMBUS_READ ? 2 : 1;
int i;
u8 partial_pec = 0; u8 partial_pec = 0;
int status; int status;
struct i2c_msg msg[2] = { struct i2c_msg msg[2] = {
...@@ -340,6 +339,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, ...@@ -340,6 +339,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
.buf = msgbuf1, .buf = msgbuf1,
}, },
}; };
bool wants_pec = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK
&& size != I2C_SMBUS_I2C_BLOCK_DATA);
msgbuf0[0] = command; msgbuf0[0] = command;
switch (size) { switch (size) {
...@@ -443,9 +444,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, ...@@ -443,9 +444,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK if (wants_pec) {
&& size != I2C_SMBUS_I2C_BLOCK_DATA);
if (i) {
/* Compute PEC if first message is a write */ /* Compute PEC if first message is a write */
if (!(msg[0].flags & I2C_M_RD)) { if (!(msg[0].flags & I2C_M_RD)) {
if (num == 1) /* Write only */ if (num == 1) /* Write only */
...@@ -468,7 +467,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, ...@@ -468,7 +467,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
status = 0; status = 0;
/* Check PEC if last message is a read */ /* Check PEC if last message is a read */
if (i && (msg[num-1].flags & I2C_M_RD)) { if (wants_pec && (msg[num-1].flags & I2C_M_RD)) {
status = i2c_smbus_check_pec(partial_pec, &msg[num-1]); status = i2c_smbus_check_pec(partial_pec, &msg[num-1]);
if (status < 0) if (status < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment