]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlxsw: i2c: Utilize standard macros for dividing buffer into chunks
authorVadim Pasternak <vadimp@nvidia.com>
Fri, 22 Sep 2023 17:18:38 +0000 (19:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Oct 2023 07:07:12 +0000 (08:07 +0100)
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>
drivers/net/ethernet/mellanox/mlxsw/i2c.c

index d23f293e285cb7c3ce785978c51a9200867d241b..1e150ce1c73a4062ca2067fcf75b90f7c40eec38 100644 (file)
@@ -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");