* [PATCH] infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey()
@ 2026-05-03 12:04 Shirin Kaul
2026-05-11 18:17 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Shirin Kaul @ 2026-05-03 12:04 UTC (permalink / raw)
To: linux-rdma; +Cc: leon, jgg, linux-kernel, Shirin Kaul
Use clamp() instead of min(max()) to make the code easier to
understand.
Signed-off-by: Shirin Kaul <shirin.kaul11@gmail.com>
---
drivers/infiniband/hw/mlx5/umr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx5/umr.c b/drivers/infiniband/hw/mlx5/umr.c
index 29488fba21a0..92b76ee65779 100644
--- a/drivers/infiniband/hw/mlx5/umr.c
+++ b/drivers/infiniband/hw/mlx5/umr.c
@@ -1014,7 +1014,7 @@ static int _mlx5r_umr_zap_mkey(struct mlx5_ib_mr *mr,
MLX5_IB_UPD_XLT_ATOMIC;
max_log_size = get_max_log_entity_size_cap(dev, access_mode);
max_page_shift = order_base_2(mr->ibmr.length);
- max_page_shift = min(max(max_page_shift, page_shift), max_log_size);
+ max_page_shift = clamp(max_page_shift, page_shift, max_log_size);
/* Count blocks in units of max_page_shift, we will zap exactly this
* many to make the whole MR non-present.
* Block size must be aligned to MLX5_UMR_FLEX_ALIGNMENT since it may
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey()
2026-05-03 12:04 [PATCH] infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey() Shirin Kaul
@ 2026-05-11 18:17 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-05-11 18:17 UTC (permalink / raw)
To: Shirin Kaul; +Cc: linux-rdma, jgg, linux-kernel
On Sun, May 03, 2026 at 12:04:57PM +0000, Shirin Kaul wrote:
> Use clamp() instead of min(max()) to make the code easier to
> understand.
>
> Signed-off-by: Shirin Kaul <shirin.kaul11@gmail.com>
> ---
> drivers/infiniband/hw/mlx5/umr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
We already discussed it there
https://lore.kernel.org/linux-rdma/20260310145727.236094-3-thorsten.blum@linux.dev/
Thanks
>
> diff --git a/drivers/infiniband/hw/mlx5/umr.c b/drivers/infiniband/hw/mlx5/umr.c
> index 29488fba21a0..92b76ee65779 100644
> --- a/drivers/infiniband/hw/mlx5/umr.c
> +++ b/drivers/infiniband/hw/mlx5/umr.c
> @@ -1014,7 +1014,7 @@ static int _mlx5r_umr_zap_mkey(struct mlx5_ib_mr *mr,
> MLX5_IB_UPD_XLT_ATOMIC;
> max_log_size = get_max_log_entity_size_cap(dev, access_mode);
> max_page_shift = order_base_2(mr->ibmr.length);
> - max_page_shift = min(max(max_page_shift, page_shift), max_log_size);
> + max_page_shift = clamp(max_page_shift, page_shift, max_log_size);
> /* Count blocks in units of max_page_shift, we will zap exactly this
> * many to make the whole MR non-present.
> * Block size must be aligned to MLX5_UMR_FLEX_ALIGNMENT since it may
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-11 18:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 12:04 [PATCH] infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey() Shirin Kaul
2026-05-11 18:17 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox