[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5e5b4d9e-b2f6-4198-b8a4-86de74a7e54e@amd.com>
Date: Sun, 17 Aug 2025 18:09:38 -0600
From: Alex Hung <alex.hung@....com>
To: Xichao Zhao <zhao.xichao@...o.com>, austin.zheng@....com,
jun.lei@....com, harry.wentland@....com, sunpeng.li@....com,
alexander.deucher@....com, christian.koenig@....com, airlied@...il.com,
simona@...ll.ch
Cc: siqueira@...lia.com, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/amd/display: replace min/max nesting with clamp()
Reviewed-by: Alex Hung <alex.hung@....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@...o.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);
>
Powered by blists - more mailing lists