]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: Simplify sorting of the bo list
authorTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Mon, 12 Jan 2026 10:22:34 +0000 (10:22 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 27 Jan 2026 23:08:29 +0000 (18:08 -0500)
Sort function only cares about the sign so we can replace the conditionals
with a single subtraction.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c

index 66fb37b643882c750f5f80078803628001507004..87ec46c56a6eec5de81f7e3307a9cd141d4a75bb 100644 (file)
@@ -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,