Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd: use clamp() in amdgpu_pll_get_fb_ref_div()

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>

authored by

Li Zetao and committed by
Alex Deucher
6fbbb660 2c7795e2

+1 -1
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_pll.c
··· 94 94 ref_div_max = min(128 / post_div, ref_div_max); 95 95 96 96 /* get matching reference and feedback divider */ 97 - *ref_div = min(max(DIV_ROUND_CLOSEST(den, post_div), 1u), ref_div_max); 97 + *ref_div = clamp(DIV_ROUND_CLOSEST(den, post_div), 1u, ref_div_max); 98 98 *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den); 99 99 100 100 /* limit fb divider to its maximum */