Skip to content

Commit f64bd79

Browse files
committed
ACPI: Keep sub-table parsing infrastructure available for modules
The NFIT driver and now the CXL ACPI driver have both open-coded ACPI table parsing. Before another instance is added arrange for the core ACPI sub-table parsing to be optionally available to drivers via the CONFIG_ACPI_TABLE_LIB symbol. If no drivers select the symbol then the infrastructure reverts back to being tagged __init via the __init_or_acpilib annotation. For now, only tag the core sub-table routines and data that the CEDT parsing in the cxl_acpi driver would want to reuse, a CEDT parsing helper is added in a later change. Cc: "Rafael J. Wysocki" <[email protected]> Cc: Len Brown <[email protected]> Cc: Alison Schofield <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/163553709227.2509508.8215196520233473814.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent 09eac2c commit f64bd79

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

drivers/acpi/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT
5959
config ACPI_CCA_REQUIRED
6060
bool
6161

62+
config ACPI_TABLE_LIB
63+
bool
64+
6265
config ACPI_DEBUGGER
6366
bool "AML debugger interface"
6467
select ACPI_DEBUG

drivers/acpi/tables.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static char *mps_inti_flags_trigger[] = { "dfl", "edge", "res", "level" };
3535

3636
static struct acpi_table_desc initial_tables[ACPI_MAX_TABLES] __initdata;
3737

38-
static int acpi_apic_instance __initdata;
38+
static int acpi_apic_instance __initdata_or_acpilib;
3939

4040
enum acpi_subtable_type {
4141
ACPI_SUBTABLE_COMMON,
@@ -52,7 +52,7 @@ struct acpi_subtable_entry {
5252
* Disable table checksum verification for the early stage due to the size
5353
* limitation of the current x86 early mapping implementation.
5454
*/
55-
static bool acpi_verify_table_checksum __initdata = false;
55+
static bool acpi_verify_table_checksum __initdata_or_acpilib = false;
5656

5757
void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
5858
{
@@ -216,7 +216,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
216216
}
217217
}
218218

219-
static unsigned long __init
219+
static unsigned long __init_or_acpilib
220220
acpi_get_entry_type(struct acpi_subtable_entry *entry)
221221
{
222222
switch (entry->type) {
@@ -230,7 +230,7 @@ acpi_get_entry_type(struct acpi_subtable_entry *entry)
230230
return 0;
231231
}
232232

233-
static unsigned long __init
233+
static unsigned long __init_or_acpilib
234234
acpi_get_entry_length(struct acpi_subtable_entry *entry)
235235
{
236236
switch (entry->type) {
@@ -244,7 +244,7 @@ acpi_get_entry_length(struct acpi_subtable_entry *entry)
244244
return 0;
245245
}
246246

247-
static unsigned long __init
247+
static unsigned long __init_or_acpilib
248248
acpi_get_subtable_header_length(struct acpi_subtable_entry *entry)
249249
{
250250
switch (entry->type) {
@@ -258,7 +258,7 @@ acpi_get_subtable_header_length(struct acpi_subtable_entry *entry)
258258
return 0;
259259
}
260260

261-
static enum acpi_subtable_type __init
261+
static enum acpi_subtable_type __init_or_acpilib
262262
acpi_get_subtable_type(char *id)
263263
{
264264
if (strncmp(id, ACPI_SIG_HMAT, 4) == 0)
@@ -291,10 +291,10 @@ acpi_get_subtable_type(char *id)
291291
* On success returns sum of all matching entries for all proc handlers.
292292
* Otherwise, -ENODEV or -EINVAL is returned.
293293
*/
294-
static int __init acpi_parse_entries_array(char *id, unsigned long table_size,
295-
struct acpi_table_header *table_header,
296-
struct acpi_subtable_proc *proc, int proc_num,
297-
unsigned int max_entries)
294+
static int __init_or_acpilib acpi_parse_entries_array(
295+
char *id, unsigned long table_size,
296+
struct acpi_table_header *table_header, struct acpi_subtable_proc *proc,
297+
int proc_num, unsigned int max_entries)
298298
{
299299
struct acpi_subtable_entry entry;
300300
unsigned long table_end, subtable_len, entry_len;
@@ -352,10 +352,9 @@ static int __init acpi_parse_entries_array(char *id, unsigned long table_size,
352352
return errs ? -EINVAL : count;
353353
}
354354

355-
int __init acpi_table_parse_entries_array(char *id,
356-
unsigned long table_size,
357-
struct acpi_subtable_proc *proc, int proc_num,
358-
unsigned int max_entries)
355+
int __init_or_acpilib acpi_table_parse_entries_array(
356+
char *id, unsigned long table_size, struct acpi_subtable_proc *proc,
357+
int proc_num, unsigned int max_entries)
359358
{
360359
struct acpi_table_header *table_header = NULL;
361360
int count;

include/linux/acpi.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,22 @@ int acpi_locate_initial_tables (void);
232232
void acpi_reserve_initial_tables (void);
233233
void acpi_table_init_complete (void);
234234
int acpi_table_init (void);
235+
236+
#ifdef CONFIG_ACPI_TABLE_LIB
237+
#define __init_or_acpilib
238+
#define __initdata_or_acpilib
239+
#else
240+
#define __init_or_acpilib __init
241+
#define __initdata_or_acpilib __initdata
242+
#endif
243+
235244
int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
236-
int __init acpi_table_parse_entries(char *id, unsigned long table_size,
237-
int entry_id,
238-
acpi_tbl_entry_handler handler,
239-
unsigned int max_entries);
240-
int __init acpi_table_parse_entries_array(char *id, unsigned long table_size,
241-
struct acpi_subtable_proc *proc, int proc_num,
242-
unsigned int max_entries);
245+
int __init_or_acpilib acpi_table_parse_entries(char *id,
246+
unsigned long table_size, int entry_id,
247+
acpi_tbl_entry_handler handler, unsigned int max_entries);
248+
int __init_or_acpilib acpi_table_parse_entries_array(char *id,
249+
unsigned long table_size, struct acpi_subtable_proc *proc,
250+
int proc_num, unsigned int max_entries);
243251
int acpi_table_parse_madt(enum acpi_madt_type id,
244252
acpi_tbl_entry_handler handler,
245253
unsigned int max_entries);

0 commit comments

Comments
 (0)