[RFC PATCH] LoongArch: Remove ACPI related ifdefs in platform_init()

From: Tiezhu Yang
Date: Tue May 14 2024 - 03:39:26 EST


acpi_table_upgrade() and acpi_boot_table_init() are defined as
empty function under !CONFIG_ACPI_TABLE_UPGRADE and !CONFIG_ACPI
in include/linux/acpi.h, there are no implicit declaration errors
with various configs. Furthermore, CONFIG_ACPI is always set due
to config ACPI is selected by config LOONGARCH. Thus, just remove
ACPI related ifdefs to call the functions directly.

#ifdef CONFIG_ACPI_TABLE_UPGRADE
void acpi_table_upgrade(void);
#else
static inline void acpi_table_upgrade(void) { }
#endif

#ifdef CONFIG_ACPI
...
void acpi_boot_table_init (void);
...
#else /* !CONFIG_ACPI */
...
static inline void acpi_boot_table_init(void)
{
}
...
#endif /* !CONFIG_ACPI */

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---

Another way is to guard the related code under CONFIG_ACPI,
but I think it is not necessary, like this:

@@ -351,10 +351,8 @@ void __init platform_init(void)
arch_reserve_vmcore();
arch_reserve_crashkernel();

-#ifdef CONFIG_ACPI_TABLE_UPGRADE
- acpi_table_upgrade();
-#endif
#ifdef CONFIG_ACPI
+ acpi_table_upgrade();
acpi_gbl_use_default_register_widths = false;
acpi_boot_table_init();
#endif

arch/loongarch/kernel/setup.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index 60e0fe97f61a..da96f871cf73 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -351,13 +351,9 @@ void __init platform_init(void)
arch_reserve_vmcore();
arch_reserve_crashkernel();

-#ifdef CONFIG_ACPI_TABLE_UPGRADE
acpi_table_upgrade();
-#endif
-#ifdef CONFIG_ACPI
acpi_gbl_use_default_register_widths = false;
acpi_boot_table_init();
-#endif

early_init_fdt_scan_reserved_mem();
unflatten_and_copy_device_tree();
--
2.42.0