From: Alex Hung <alex.hung@amd.com>
To: Xichao Zhao <zhao.xichao@vivo.com>,
austin.zheng@amd.com, jun.lei@amd.com, harry.wentland@amd.com,
sunpeng.li@amd.com, alexander.deucher@amd.com,
christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch
Cc: siqueira@igalia.com, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: replace min/max nesting with clamp()
Date: Sun, 17 Aug 2025 18:09:38 -0600 [thread overview]
Message-ID: <5e5b4d9e-b2f6-4198-b8a4-86de74a7e54e@amd.com> (raw)
In-Reply-To: <20250808025209.120448-1-zhao.xichao@vivo.com>
Reviewed-by: Alex Hung <alex.hung@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@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);
>
prev parent reply other threads:[~2025-08-18 0:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 2:52 Xichao Zhao
2025-08-18 0:09 ` Alex Hung [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e5b4d9e-b2f6-4198-b8a4-86de74a7e54e@amd.com \
--to=alex.hung@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=austin.zheng@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=jun.lei@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.com \
--cc=zhao.xichao@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®