arch: fix asm-offsets.c building with -Wmissing-prototypes

When -Wmissing-prototypes is enabled, the some asm-offsets.c files fail
to build, even when this warning is disabled in the Makefile for normal
files:

arch/sparc/kernel/asm-offsets.c:22:5: error: no previous prototype for 'sparc32_foo' [-Werror=missing-prototypes]
arch/sparc/kernel/asm-offsets.c:48:5: error: no previous prototype for 'foo' [-Werror=missing-prototypes]

Address this by making use of the same trick as x86, marking these
functions as 'static __used' to avoid the need for a prototype
by not drop them in dead-code elimination.

Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://lore.kernel.org/lkml/CAK7LNARfEmFk0Du4Hed19eX_G6tUC5wG0zP+L1AyvdpOF4ybXQ@mail.gmail.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2023-11-08 13:58:30 +01:00
parent 64bac5ea17
commit 4d86896793
3 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,7 @@
#include <linux/kbuild.h>
#include <asm/io.h>
void foo(void)
static void __used foo(void)
{
DEFINE(TI_TASK, offsetof(struct thread_info, task));
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));

View File

@ -15,7 +15,7 @@
#include <asm/processor.h>
#include <asm/ftrace.h>
void output_ptreg_defines(void)
static void __used output_ptreg_defines(void)
{
COMMENT("LoongArch pt_regs offsets.");
OFFSET(PT_R0, pt_regs, regs[0]);
@ -62,7 +62,7 @@ void output_ptreg_defines(void)
BLANK();
}
void output_task_defines(void)
static void __used output_task_defines(void)
{
COMMENT("LoongArch task_struct offsets.");
OFFSET(TASK_STATE, task_struct, __state);
@ -77,7 +77,7 @@ void output_task_defines(void)
BLANK();
}
void output_thread_info_defines(void)
static void __used output_thread_info_defines(void)
{
COMMENT("LoongArch thread_info offsets.");
OFFSET(TI_TASK, thread_info, task);
@ -93,7 +93,7 @@ void output_thread_info_defines(void)
BLANK();
}
void output_thread_defines(void)
static void __used output_thread_defines(void)
{
COMMENT("LoongArch specific thread_struct offsets.");
OFFSET(THREAD_REG01, task_struct, thread.reg01);
@ -129,7 +129,7 @@ void output_thread_defines(void)
BLANK();
}
void output_thread_fpu_defines(void)
static void __used output_thread_fpu_defines(void)
{
OFFSET(THREAD_FPR0, loongarch_fpu, fpr[0]);
OFFSET(THREAD_FPR1, loongarch_fpu, fpr[1]);
@ -170,7 +170,7 @@ void output_thread_fpu_defines(void)
BLANK();
}
void output_thread_lbt_defines(void)
static void __used output_thread_lbt_defines(void)
{
OFFSET(THREAD_SCR0, loongarch_lbt, scr0);
OFFSET(THREAD_SCR1, loongarch_lbt, scr1);
@ -180,7 +180,7 @@ void output_thread_lbt_defines(void)
BLANK();
}
void output_mm_defines(void)
static void __used output_mm_defines(void)
{
COMMENT("Size of struct page");
DEFINE(STRUCT_PAGE_SIZE, sizeof(struct page));
@ -212,7 +212,7 @@ void output_mm_defines(void)
BLANK();
}
void output_sc_defines(void)
static void __used output_sc_defines(void)
{
COMMENT("Linux sigcontext offsets.");
OFFSET(SC_REGS, sigcontext, sc_regs);
@ -220,7 +220,7 @@ void output_sc_defines(void)
BLANK();
}
void output_signal_defines(void)
static void __used output_signal_defines(void)
{
COMMENT("Linux signal numbers.");
DEFINE(_SIGHUP, SIGHUP);
@ -258,7 +258,7 @@ void output_signal_defines(void)
}
#ifdef CONFIG_SMP
void output_smpboot_defines(void)
static void __used output_smpboot_defines(void)
{
COMMENT("Linux smp cpu boot offsets.");
OFFSET(CPU_BOOT_STACK, secondary_data, stack);
@ -268,7 +268,7 @@ void output_smpboot_defines(void)
#endif
#ifdef CONFIG_HIBERNATION
void output_pbe_defines(void)
static void __used output_pbe_defines(void)
{
COMMENT("Linux struct pbe offsets.");
OFFSET(PBE_ADDRESS, pbe, address);
@ -280,7 +280,7 @@ void output_pbe_defines(void)
#endif
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
void output_fgraph_ret_regs_defines(void)
static void __used output_fgraph_ret_regs_defines(void)
{
COMMENT("LoongArch fgraph_ret_regs offsets.");
OFFSET(FGRET_REGS_A0, fgraph_ret_regs, regs[0]);
@ -291,7 +291,7 @@ void output_fgraph_ret_regs_defines(void)
}
#endif
void output_kvm_defines(void)
static void __used output_kvm_defines(void)
{
COMMENT("KVM/LoongArch Specific offsets.");

View File

@ -19,14 +19,14 @@
#include <asm/hibernate.h>
#ifdef CONFIG_SPARC32
int sparc32_foo(void)
static int __used sparc32_foo(void)
{
DEFINE(AOFF_thread_fork_kpsr,
offsetof(struct thread_struct, fork_kpsr));
return 0;
}
#else
int sparc64_foo(void)
static int __used sparc64_foo(void)
{
#ifdef CONFIG_HIBERNATION
BLANK();
@ -45,7 +45,7 @@ int sparc64_foo(void)
}
#endif
int foo(void)
static int __used foo(void)
{
BLANK();
DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread));