From: Xichao Zhao Date: Tue, 12 Aug 2025 03:16:03 +0000 (+0800) Subject: drm/radeon: replace min/max nesting with clamp() X-Git-Tag: v6.18-rc1~134^2~19^2~105 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e03525ce15cb9fc633b3d0266866020e22ce5e6;p=thirdparty%2Flinux.git drm/radeon: replace min/max nesting with clamp() The clamp() macro explicitly expresses the intent of constraining a value within bounds.Therefore, replacing min(max(a, b), c) and max(min(a,b),c) with clamp(val, lo, hi) can improve code readability. Reviewed-by: Christian König Signed-off-by: Xichao Zhao Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index b4bf5dfeea2dc..d66c1a30df951 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c @@ -926,10 +926,10 @@ static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div, unsigned *fb_div, unsigned *ref_div) { /* limit reference * post divider to a maximum */ - ref_div_max = max(min(100 / post_div, ref_div_max), 1u); + ref_div_max = clamp(100 / post_div, 1u, ref_div_max); /* get matching reference and feedback divider */ - *ref_div = min(max(den/post_div, 1u), ref_div_max); + *ref_div = clamp(den / post_div, 1u, ref_div_max); *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den); /* limit fb divider to its maximum */