Skip to content

Commit 931abcd

Browse files
committed
Merge branch 'mlxsw-fixes'
Petr Machata says: ==================== mlxsw: Assorted fixes This patchset contains several fixes for the mlxsw driver. Patch #1 - Fixes buffer size in I2C mailbox buffer. Patch #2 - Sets limitation of chunk size in I2C transaction. Patch #3 - Fixes module label names based on MTCAP sensor counter ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 786c96e + 3fc134a commit 931abcd

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ mlxsw_hwmon_module_temp_label_show(struct device *dev,
405405
container_of(attr, struct mlxsw_hwmon_attr, dev_attr);
406406

407407
return sprintf(buf, "front panel %03u\n",
408-
mlxsw_hwmon_attr->type_index);
408+
mlxsw_hwmon_attr->type_index + 1 -
409+
mlxsw_hwmon_attr->mlxsw_hwmon_dev->sensor_count);
409410
}
410411

411412
static ssize_t

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

Lines changed: 3 additions & 2 deletions
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
@@ -444,7 +445,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size,
444445
} else {
445446
/* No input mailbox is case of initialization query command. */
446447
reg_size = MLXSW_I2C_MAX_DATA_SIZE;
447-
num = reg_size / mlxsw_i2c->block_size;
448+
num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size);
448449

449450
if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) {
450451
dev_err(&client->dev, "Could not acquire lock");
@@ -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)