Skip to contentSkip to conversation

infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey()

PATCH In review Shirin Kaul 2 participants 2 messages May 3 – May 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband: hw : use clamp() in _mlx5r_umr_zap_mkey()

Use clamp() instead of min(max()) to make the code easier to understand.

---
 drivers/infiniband/hw/mlx5/umr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/umr.c +1 -1
index 29488fba21a0..92b76ee65779 100644
@@ -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
Signature · 1 line
2.43.0
#1 lore raw
Quoted 7 lines · Shirin Kaul

Use clamp() instead of min(max()) to make the code easier to understand.

---
 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/[email protected]/

Thanks

Quoted 17 lines
drivers/infiniband/hw/mlx5/umr.c +1 -1
index 29488fba21a0..92b76ee65779 100644
@@ -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
Signature · 1 line
2.43.0