[PATCH] drm/amd/display: replace min/max nesting with clamp()
Alex Hung
alex.hung at amd.com
Mon Aug 18 00:09:38 UTC 2025
Reviewed-by: Alex Hung <alex.hung at amd.com>
On 8/7/25 20:52, Xichao Zhao wrote:
> The clamp() macro explicitly expresses the intent of constraining
> a value within bounds.Therefore, replacing min(max(a, b), c) with
> clamp(val, lo, hi) can improve code readability.
>
> Signed-off-by: Xichao Zhao <zhao.xichao at vivo.com>
> ---
> drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c
> index 0c0b2d67c9cd..00767b8ccdae 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c
> @@ -435,12 +435,12 @@ void dcn301_fpu_calculate_wm_and_dlg(struct dc *dc,
> &context->bw_ctx.dml, pipes, pipe_cnt);
> /* WM Set C */
> table_entry = &bw_params->wm_table.entries[WM_C];
> - vlevel = min(max(vlevel_req, 2), vlevel_max);
> + vlevel = clamp(vlevel_req, 2, vlevel_max);
> calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.c,
> &context->bw_ctx.dml, pipes, pipe_cnt);
> /* WM Set B */
> table_entry = &bw_params->wm_table.entries[WM_B];
> - vlevel = min(max(vlevel_req, 1), vlevel_max);
> + vlevel = clamp(vlevel_req, 1, vlevel_max);
> calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.b,
> &context->bw_ctx.dml, pipes, pipe_cnt);
>
More information about the amd-gfx
mailing list