Skip to content

Commit

Permalink
mlxsw: i2c: Utilize standard macros for dividing buffer into chunks
Browse files Browse the repository at this point in the history
Use standard macro DIV_ROUND_UP() to determine the number of chunks
required for a given buffer.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vadim Pasternak authored and David S. Miller committed Oct 2, 2023
1 parent 7afc79e commit 1f73286
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/ethernet/mellanox/mlxsw/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@ mlxsw_i2c_cmd(struct device *dev, u16 opcode, u32 in_mod, size_t in_mbox_size,

if (in_mbox) {
reg_size = mlxsw_i2c_get_reg_size(in_mbox);
num = reg_size / mlxsw_i2c->block_size;
if (reg_size % mlxsw_i2c->block_size)
num++;
num = DIV_ROUND_UP(reg_size, mlxsw_i2c->block_size);

if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) {
dev_err(&client->dev, "Could not acquire lock");
Expand Down

0 comments on commit 1f73286

Please sign in to comment.