| .. | .. |
|---|
| 47 | 47 | #define MLXSW_I2C_MBOX_SIZE_BITS 12 |
|---|
| 48 | 48 | #define MLXSW_I2C_ADDR_BUF_SIZE 4 |
|---|
| 49 | 49 | #define MLXSW_I2C_BLK_DEF 32 |
|---|
| 50 | +#define MLXSW_I2C_BLK_MAX 100 |
|---|
| 50 | 51 | #define MLXSW_I2C_RETRY 5 |
|---|
| 51 | 52 | #define MLXSW_I2C_TIMEOUT_MSECS 5000 |
|---|
| 52 | 53 | #define MLXSW_I2C_MAX_DATA_SIZE 256 |
|---|
| .. | .. |
|---|
| 428 | 429 | } else { |
|---|
| 429 | 430 | /* No input mailbox is case of initialization query command. */ |
|---|
| 430 | 431 | reg_size = MLXSW_I2C_MAX_DATA_SIZE; |
|---|
| 431 | | - num = reg_size / mlxsw_i2c->block_size; |
|---|
| 432 | + num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size); |
|---|
| 432 | 433 | |
|---|
| 433 | 434 | if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) { |
|---|
| 434 | 435 | dev_err(&client->dev, "Could not acquire lock"); |
|---|
| .. | .. |
|---|
| 576 | 577 | return -EOPNOTSUPP; |
|---|
| 577 | 578 | } |
|---|
| 578 | 579 | |
|---|
| 579 | | - mlxsw_i2c->block_size = max_t(u16, MLXSW_I2C_BLK_DEF, |
|---|
| 580 | + mlxsw_i2c->block_size = min_t(u16, MLXSW_I2C_BLK_MAX, |
|---|
| 580 | 581 | min_t(u16, quirks->max_read_len, |
|---|
| 581 | 582 | quirks->max_write_len)); |
|---|
| 582 | 583 | } else { |
|---|