]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: replace min/max nesting with clamp()
authorXichao Zhao <zhao.xichao@vivo.com>
Fri, 8 Aug 2025 02:52:09 +0000 (10:52 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 18 Aug 2025 21:01:32 +0000 (17:01 -0400)
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>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml/dcn301/dcn301_fpu.c

index 2066a65c69bbcca463bf4423a5f2e681e2d4c527..1aaa77265eede95c5aa8f910f94f0d442aee1ede 100644 (file)
@@ -449,12 +449,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);