[PATCH v1] LoongArch: Use generic cmp_int() instead of custom cmp_3way()
From: Tiezhu Yang
Date: Fri Jul 17 2026 - 05:51:06 EST
Currently, the module-sections.c file defines a custom cmp_3way() macro to
perform a three-way comparison. There is already a generic cmp_int() macro
to do the same thing in linux/sort.h, thus remove the custom macro and use
the generic interface. This is similar with commit 3e17a4b443bb ("riscv:
module: Use generic cmp_int() instead of custom cmp_3way()").
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
arch/loongarch/kernel/module-sections.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/loongarch/kernel/module-sections.c b/arch/loongarch/kernel/module-sections.c
index 9fa1c9814fcc..0259d9c7ea30 100644
--- a/arch/loongarch/kernel/module-sections.c
+++ b/arch/loongarch/kernel/module-sections.c
@@ -62,16 +62,14 @@ Elf_Addr module_emit_plt_entry(struct module *mod, Elf_Shdr *sechdrs, Elf_Addr v
return (Elf_Addr)&plt[nr];
}
-#define cmp_3way(a, b) ((a) < (b) ? -1 : (a) > (b))
-
static int compare_rela(const void *x, const void *y)
{
int ret;
const Elf_Rela *rela_x = x, *rela_y = y;
- ret = cmp_3way(rela_x->r_info, rela_y->r_info);
+ ret = cmp_int(rela_x->r_info, rela_y->r_info);
if (ret == 0)
- ret = cmp_3way(rela_x->r_addend, rela_y->r_addend);
+ ret = cmp_int(rela_x->r_addend, rela_y->r_addend);
return ret;
}
--
2.42.0