]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/alternatives: Simplify and clean up patch_cmp()
authorIngo Molnar <mingo@kernel.org>
Fri, 11 Apr 2025 05:40:55 +0000 (07:40 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 11 Apr 2025 09:01:35 +0000 (11:01 +0200)
- No need to cast over to 'struct smp_text_poke_loc *', void * is just fine
  for a binary search,

- Use the canonical (a, b) input parameter nomenclature of cmp_func_t
  functions and rename the input parameters from (tp, elt) to
  (tpl_a, tpl_b).

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250411054105.2341982-44-mingo@kernel.org
arch/x86/kernel/alternative.c

index 14ca17dc36e82beed6e6dc4e036413b4c647e127..f278655f0950192db43fddce2a6002cb875d1b02 100644 (file)
@@ -2498,13 +2498,11 @@ static __always_inline void *text_poke_addr(const struct smp_text_poke_loc *tp)
        return _stext + tp->rel_addr;
 }
 
-static __always_inline int patch_cmp(const void *key, const void *elt)
+static __always_inline int patch_cmp(const void *tpl_a, const void *tpl_b)
 {
-       struct smp_text_poke_loc *tp = (struct smp_text_poke_loc *) elt;
-
-       if (key < text_poke_addr(tp))
+       if (tpl_a < text_poke_addr(tpl_b))
                return -1;
-       if (key > text_poke_addr(tp))
+       if (tpl_a > text_poke_addr(tpl_b))
                return 1;
        return 0;
 }