From: Rohit Chavan Date: Tue, 5 May 2026 10:05:49 +0000 (+0530) Subject: RDMA/mlx5: Use max() macro for bfreg calculation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e456dc2d81a6b43c7ace4036cceea7a822d17a13;p=thirdparty%2Fkernel%2Flinux.git RDMA/mlx5: Use max() macro for bfreg calculation Simplify the calculation of medium blue flame registers by using the max() macro instead of open-coded ternary logic. This improves readability and aligns with the subsystem's preference for using standard kernel helpers. Signed-off-by: Rohit Chavan Link: https://patch.msgid.link/20260505100550.1810139-1-roheetchavan@gmail.com Signed-off-by: Leon Romanovsky --- diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 8f50e7342a769..3048d2d273d74 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -703,12 +703,8 @@ static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi) static int num_med_bfreg(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi) { - int n; - - n = max_bfregs(dev, bfregi) - bfregi->num_low_latency_bfregs - - NUM_NON_BLUE_FLAME_BFREGS; - - return n >= 0 ? n : 0; + return max(0, max_bfregs(dev, bfregi) - bfregi->num_low_latency_bfregs - + NUM_NON_BLUE_FLAME_BFREGS); } static int first_med_bfreg(struct mlx5_ib_dev *dev,