Commit 27b16364 authored by Xichao Zhao's avatar Xichao Zhao Committed by Alex Deucher
Browse files

drm/amd/display: replace min/max nesting with clamp()



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: default avatarXichao Zhao <zhao.xichao@vivo.com>
Reviewed-by: default avatarAlex Hung <alex.hung@amd.com>
Tested-by: default avatarDan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5599b214
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);