]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/amd: use clamp() in amdgpu_pll_get_fb_ref_div()
authorLi Zetao <lizetao1@huawei.com>
Fri, 30 Aug 2024 01:22:14 +0000 (09:22 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 6 Sep 2024 21:38:53 +0000 (17:38 -0400)
When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c

index 0bb2466d539a91825cbd0e5854dfcf8852a86cc5..675aa138ea112550be9c29189e3c1e319d2cc192 100644 (file)
@@ -94,7 +94,7 @@ static void amdgpu_pll_get_fb_ref_div(struct amdgpu_device *adev, unsigned int n
                ref_div_max = min(128 / post_div, ref_div_max);
 
        /* get matching reference and feedback divider */
-       *ref_div = min(max(DIV_ROUND_CLOSEST(den, post_div), 1u), ref_div_max);
+       *ref_div = clamp(DIV_ROUND_CLOSEST(den, post_div), 1u, ref_div_max);
        *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den);
 
        /* limit fb divider to its maximum */