From dda702172dc26e080fe048b8f170eaccb8097c1a Mon Sep 17 00:00:00 2001 From: Tvrtko Ursulin Date: Mon, 12 Jan 2026 10:22:34 +0000 Subject: [PATCH] drm/amdgpu: Simplify sorting of the bo list MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Sort function only cares about the sign so we can replace the conditionals with a single subtraction. Signed-off-by: Tvrtko Ursulin Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 66fb37b643882..87ec46c56a6ee 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -60,11 +60,9 @@ static int amdgpu_bo_list_entry_cmp(const void *_a, const void *_b) { const struct amdgpu_bo_list_entry *a = _a, *b = _b; - if (a->priority > b->priority) - return 1; - if (a->priority < b->priority) - return -1; - return 0; + BUILD_BUG_ON(AMDGPU_BO_LIST_MAX_PRIORITY >= INT_MAX); + + return (int)a->priority - (int)b->priority; } int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp, -- 2.47.3