From: "Christian König" <christian.koenig@amd.com>
To: Xichao Zhao <zhao.xichao@vivo.com>,
alexander.deucher@amd.com, airlied@gmail.com, simona@ffwll.ch
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/radeon: replace min/max nesting with clamp()
Date: Tue, 12 Aug 2025 08:49:07 +0200 [thread overview]
Message-ID: <0811e8e8-5990-4880-a2cc-f9bd6b3ec4bd@amd.com> (raw)
In-Reply-To: <20250812031603.463355-1-zhao.xichao@vivo.com>
On 12.08.25 05:16, Xichao Zhao wrote:
> The clamp() macro explicitly expresses the intent of constraining
> a value within bounds.Therefore, replacing min(max(a, b), c) and
> max(min(a,b),c) with clamp(val, lo, hi) can improve code readability.
>
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_display.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index b4bf5dfeea2d..d66c1a30df95 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -926,10 +926,10 @@ static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div,
> unsigned *fb_div, unsigned *ref_div)
> {
> /* limit reference * post divider to a maximum */
> - ref_div_max = max(min(100 / post_div, ref_div_max), 1u);
> + ref_div_max = clamp(100 / post_div, 1u, ref_div_max);
>
> /* get matching reference and feedback divider */
> - *ref_div = min(max(den/post_div, 1u), ref_div_max);
> + *ref_div = clamp(den / post_div, 1u, ref_div_max);
> *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den);
>
> /* limit fb divider to its maximum */
next prev parent reply other threads:[~2025-08-12 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 3:16 Xichao Zhao
2025-08-12 6:49 ` Christian König [this message]
2025-08-12 16:30 ` Alex Deucher
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=0811e8e8-5990-4880-a2cc-f9bd6b3ec4bd@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--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®