]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/nouveau/volt: use clamp() in nvkm_volt_map()
authorLi Zetao <lizetao1@huawei.com>
Sat, 31 Aug 2024 01:28:03 +0000 (09:28 +0800)
committerLyude Paul <lyude@redhat.com>
Wed, 4 Sep 2024 19:21:43 +0000 (15:21 -0400)
When it needs to get a value within a certain interval, using clamp()
makes the code easier to understand than min(max()).

Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240831012803.3950100-4-lizetao1@huawei.com
drivers/gpu/drm/nouveau/nvkm/subdev/volt/base.c

index a17a6dd8d3de9066df9d8f3e074f3b5f43be8e29..803b98df4858f9c511d63f22fc203fe2db777a71 100644 (file)
@@ -142,7 +142,7 @@ nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temp)
                        return -ENODEV;
                }
 
-               result = min(max(result, (s64)info.min), (s64)info.max);
+               result = clamp(result, (s64)info.min, (s64)info.max);
 
                if (info.link != 0xff) {
                        int ret = nvkm_volt_map(volt, info.link, temp);