Re: [RFC PATCH v3 03/11] powerpc/module_64: Convert #ifdef to IS_ENABLED()

Nicholas Piggin
2024-07-01T09:02:02Z

On Fri Jun 21, 2024 at 4:54 AM AEST, Naveen N Rao wrote:
> Minor refactor for converting #ifdef to IS_ENABLED().
>
> Signed-off-by: Naveen N Rao <naveen@kernel.org>
> ---
> arch/powerpc/kernel/module_64.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
> index e9bab599d0c2..c202be11683b 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -241,14 +241,13 @@ static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
> }
> }
>
> -#ifdef CONFIG_DYNAMIC_FTRACE
> /* make the trampoline to the ftrace_caller */
> - relocs++;
> -#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> + if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE))
> + relocs++;
> +
> /* an additional one for ftrace_regs_caller */
> - relocs++;
> -#endif
> -#endif
> + if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
> + relocs++;
>
> pr_debug("Looks like a total of %lu stubs, max\n", relocs);
> return relocs * sizeof(struct ppc64_stub_entry);

LGTM. Hmm, you could get even cleverer

// make the trampoline to the ftrace_caller and ftrace_regs_caller
relocs += IS_ENABLED(CONFIG_DYNAMIC_FTRACE) +
IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS);

But either way

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

Thanks,
Nick