Skip to content

Commit d7248f1

Browse files
vadimp-nvidiadavem330
authored andcommitted
mlxsw: i2c: Limit single transaction buffer size
Maximum size of buffer is obtained from underlying I2C adapter and in case adapter allows I2C transaction buffer size greater than 100 bytes, transaction will fail due to firmware limitation. As a result driver will fail initialization. Limit the maximum size of transaction buffer by 100 bytes to fit to firmware. Remove unnecessary calculation: max_t(u16, MLXSW_I2C_BLK_DEF, quirk_size). This condition can not happened. Fixes: 3029a69 ("mlxsw: i2c: Allow flexible setting of I2C transactions size") Signed-off-by: Vadim Pasternak <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 146c7c3 commit d7248f1

File tree

1 file changed

+2
-1
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+2
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/i2c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define MLXSW_I2C_MBOX_SIZE_BITS 12
4949
#define MLXSW_I2C_ADDR_BUF_SIZE 4
5050
#define MLXSW_I2C_BLK_DEF 32
51+
#define MLXSW_I2C_BLK_MAX 100
5152
#define MLXSW_I2C_RETRY 5
5253
#define MLXSW_I2C_TIMEOUT_MSECS 5000
5354
#define MLXSW_I2C_MAX_DATA_SIZE 256
@@ -653,7 +654,7 @@ static int mlxsw_i2c_probe(struct i2c_client *client)
653654
return -EOPNOTSUPP;
654655
}
655656

656-
mlxsw_i2c->block_size = max_t(u16, MLXSW_I2C_BLK_DEF,
657+
mlxsw_i2c->block_size = min_t(u16, MLXSW_I2C_BLK_MAX,
657658
min_t(u16, quirks->max_read_len,
658659
quirks->max_write_len));
659660
} else {

0 commit comments

Comments
 (0)