diff options
author | Vadim Pasternak <vadimp@mellanox.com> | 2017-11-01 07:10:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-01 07:40:58 -0400 |
commit | d70eaa386bf9ecc1e5b3002f64eb59172fcec4fd (patch) | |
tree | e7ec45ab653b8941a19d360e22d2e9af8000ecb2 | |
parent | 122f00cdc1bb27cb0ff4b0a8cffa3bb27f61f949 (diff) |
mlxsw: i2c: Fix buffer increment counter for write transaction
It fixes a problem for the last chunk where 'chunk_size' is smaller than
MLXSW_I2C_BLK_MAX and data is copied to the wrong offset, overriding
previous data.
Fixes: 6882b0aee180 ("mlxsw: Introduce support for I2C bus")
Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/i2c.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/i2c.c b/drivers/net/ethernet/mellanox/mlxsw/i2c.c index 12c3a4449120..c0dcfa05b077 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/i2c.c +++ b/drivers/net/ethernet/mellanox/mlxsw/i2c.c | |||
@@ -294,7 +294,7 @@ mlxsw_i2c_write(struct device *dev, size_t in_mbox_size, u8 *in_mbox, int num, | |||
294 | write_tran.len = MLXSW_I2C_ADDR_WIDTH + chunk_size; | 294 | write_tran.len = MLXSW_I2C_ADDR_WIDTH + chunk_size; |
295 | mlxsw_i2c_set_slave_addr(tran_buf, off); | 295 | mlxsw_i2c_set_slave_addr(tran_buf, off); |
296 | memcpy(&tran_buf[MLXSW_I2C_ADDR_BUF_SIZE], in_mbox + | 296 | memcpy(&tran_buf[MLXSW_I2C_ADDR_BUF_SIZE], in_mbox + |
297 | chunk_size * i, chunk_size); | 297 | MLXSW_I2C_BLK_MAX * i, chunk_size); |
298 | 298 | ||
299 | j = 0; | 299 | j = 0; |
300 | end = jiffies + timeout; | 300 | end = jiffies + timeout; |