Skip to content

Commit af0cf16

Browse files
committed
x86/boot/e820: Standardize __init/__initdata tag placement
So the e820.c file has a hodgepodge of __init and __initdata tag placements: static int __init e820_search_gap(unsigned long *max_gap_start, unsigned long *max_gap_size) __init void e820__setup_pci_gap(void) __init void e820__reallocate_tables(void) void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len) void __init e820__register_nosave_regions(unsigned long limit_pfn) static int __init e820__register_nvs_regions(void) u64 __init e820__memblock_alloc_reserved(u64 size, u64 align) Standardize on the style used by e820__setup_pci_gap() and place them before the storage class. In addition to the consistency, as a bonus this makes the grep output rather clean looking: __init void e820__range_remove(u64 start, u64 size, enum e820_type filter_type) __init void e820__update_table_print(void) __init static void e820__update_table_kexec(void) __init static int e820_search_gap(unsigned long *max_gap_start, unsigned long *max_gap_size) __init void e820__setup_pci_gap(void) __init void e820__reallocate_tables(void) __init void e820__memory_setup_extended(u64 phys_addr, u32 data_len) __init void e820__register_nosave_regions(unsigned long limit_pfn) __init static int e820__register_nvs_regions(void) ... and if one learns to just ignore the leftmost '__init' noise then the rest of the line looks just like a regular C function definition. With the 'mixed' tag placement style the __init tag breaks up the function's prototype for no good reason. Do the same for __initdata. Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: H . Peter Anvin <hpa@zytor.com> Cc: Andy Shevchenko <andy@kernel.org> Cc: Arnd Bergmann <arnd@kernel.org> Cc: David Woodhouse <dwmw@amazon.co.uk> Cc: Juergen Gross <jgross@suse.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Rapoport <rppt@kernel.org> Cc: Paul Menzel <pmenzel@molgen.mpg.de> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://patch.msgid.link/20250515120549.2820541-25-mingo@kernel.org
1 parent 7df2f81 commit af0cf16

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

arch/x86/kernel/e820.c

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
* re-propagated. So its main role is a temporary bootstrap storage of firmware
5656
* specific memory layout data during early bootup.
5757
*/
58-
static struct e820_table e820_table_init __initdata;
59-
static struct e820_table e820_table_kexec_init __initdata;
60-
static struct e820_table e820_table_firmware_init __initdata;
58+
__initdata static struct e820_table e820_table_init;
59+
__initdata static struct e820_table e820_table_kexec_init;
60+
__initdata static struct e820_table e820_table_firmware_init;
6161

6262
__refdata struct e820_table *e820_table = &e820_table_init;
6363
__refdata struct e820_table *e820_table_kexec = &e820_table_kexec_init;
@@ -144,7 +144,7 @@ static struct e820_entry *__e820__mapped_all(u64 start, u64 end,
144144
/*
145145
* This function checks if the entire range <start,end> is mapped with type.
146146
*/
147-
bool __init e820__mapped_all(u64 start, u64 end, enum e820_type type)
147+
__init bool e820__mapped_all(u64 start, u64 end, enum e820_type type)
148148
{
149149
return __e820__mapped_all(start, end, type);
150150
}
@@ -162,7 +162,7 @@ int e820__get_entry_type(u64 start, u64 end)
162162
/*
163163
* Add a memory region to the kernel E820 map.
164164
*/
165-
static void __init __e820__range_add(struct e820_table *table, u64 start, u64 size, enum e820_type type)
165+
__init static void __e820__range_add(struct e820_table *table, u64 start, u64 size, enum e820_type type)
166166
{
167167
u32 idx = table->nr_entries;
168168
struct e820_entry *entry_new;
@@ -182,12 +182,12 @@ static void __init __e820__range_add(struct e820_table *table, u64 start, u64 si
182182
table->nr_entries++;
183183
}
184184

185-
void __init e820__range_add(u64 start, u64 size, enum e820_type type)
185+
__init void e820__range_add(u64 start, u64 size, enum e820_type type)
186186
{
187187
__e820__range_add(e820_table, start, size, type);
188188
}
189189

190-
static void __init e820_print_type(enum e820_type type)
190+
__init static void e820_print_type(enum e820_type type)
191191
{
192192
switch (type) {
193193
case E820_TYPE_RAM: pr_cont(" System RAM"); break;
@@ -202,7 +202,7 @@ static void __init e820_print_type(enum e820_type type)
202202
}
203203
}
204204

205-
static void __init e820__print_table(const char *who)
205+
__init static void e820__print_table(const char *who)
206206
{
207207
u64 range_end_prev = 0;
208208
u32 idx;
@@ -301,12 +301,12 @@ struct change_member {
301301
u64 addr;
302302
};
303303

304-
static struct change_member change_point_list[2*E820_MAX_ENTRIES] __initdata;
305-
static struct change_member *change_point[2*E820_MAX_ENTRIES] __initdata;
306-
static struct e820_entry *overlap_list[E820_MAX_ENTRIES] __initdata;
307-
static struct e820_entry new_entries[E820_MAX_ENTRIES] __initdata;
304+
__initdata static struct change_member change_point_list[2*E820_MAX_ENTRIES];
305+
__initdata static struct change_member *change_point[2*E820_MAX_ENTRIES];
306+
__initdata static struct e820_entry *overlap_list[E820_MAX_ENTRIES];
307+
__initdata static struct e820_entry new_entries[E820_MAX_ENTRIES];
308308

309-
static int __init cpcompare(const void *a, const void *b)
309+
__init static int cpcompare(const void *a, const void *b)
310310
{
311311
struct change_member * const *app = a, * const *bpp = b;
312312
const struct change_member *ap = *app, *bp = *bpp;
@@ -341,7 +341,7 @@ static bool e820_type_mergeable(enum e820_type type)
341341
return true;
342342
}
343343

344-
int __init e820__update_table(struct e820_table *table)
344+
__init int e820__update_table(struct e820_table *table)
345345
{
346346
struct e820_entry *entries = table->entries;
347347
u32 max_nr_entries = ARRAY_SIZE(table->entries);
@@ -441,7 +441,7 @@ int __init e820__update_table(struct e820_table *table)
441441
return 0;
442442
}
443443

444-
static int __init __append_e820_table(struct boot_e820_entry *entries, u32 nr_entries)
444+
__init static int __append_e820_table(struct boot_e820_entry *entries, u32 nr_entries)
445445
{
446446
struct boot_e820_entry *entry = entries;
447447

@@ -472,7 +472,7 @@ static int __init __append_e820_table(struct boot_e820_entry *entries, u32 nr_en
472472
* will have given us a memory map that we can use to properly
473473
* set up memory. If we aren't, we'll fake a memory map.
474474
*/
475-
static int __init append_e820_table(struct boot_e820_entry *entries, u32 nr_entries)
475+
__init static int append_e820_table(struct boot_e820_entry *entries, u32 nr_entries)
476476
{
477477
/* Only one memory region (or negative)? Ignore it */
478478
if (nr_entries < 2)
@@ -481,7 +481,7 @@ static int __init append_e820_table(struct boot_e820_entry *entries, u32 nr_entr
481481
return __append_e820_table(entries, nr_entries);
482482
}
483483

484-
static u64 __init
484+
__init static u64
485485
__e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
486486
{
487487
u64 end;
@@ -549,19 +549,19 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty
549549
return real_updated_size;
550550
}
551551

552-
u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
552+
__init u64 e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type)
553553
{
554554
return __e820__range_update(e820_table, start, size, old_type, new_type);
555555
}
556556

557-
u64 __init e820__range_update_table(struct e820_table *t, u64 start, u64 size,
557+
__init u64 e820__range_update_table(struct e820_table *t, u64 start, u64 size,
558558
enum e820_type old_type, enum e820_type new_type)
559559
{
560560
return __e820__range_update(t, start, size, old_type, new_type);
561561
}
562562

563563
/* Remove a range of memory from the E820 table: */
564-
u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
564+
__init u64 e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
565565
{
566566
u32 idx;
567567
u64 end;
@@ -622,7 +622,7 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool
622622
return real_removed_size;
623623
}
624624

625-
void __init e820__update_table_print(void)
625+
__init void e820__update_table_print(void)
626626
{
627627
if (e820__update_table(e820_table))
628628
return;
@@ -631,7 +631,7 @@ void __init e820__update_table_print(void)
631631
e820__print_table("modified");
632632
}
633633

634-
static void __init e820__update_table_kexec(void)
634+
__init static void e820__update_table_kexec(void)
635635
{
636636
e820__update_table(e820_table_kexec);
637637
}
@@ -641,7 +641,7 @@ static void __init e820__update_table_kexec(void)
641641
/*
642642
* Search for a gap in the E820 memory space from 0 to MAX_GAP_END (4GB).
643643
*/
644-
static int __init e820_search_gap(unsigned long *max_gap_start, unsigned long *max_gap_size)
644+
__init static int e820_search_gap(unsigned long *max_gap_start, unsigned long *max_gap_size)
645645
{
646646
u64 last = MAX_GAP_END;
647647
int idx = e820_table->nr_entries;
@@ -744,7 +744,7 @@ __init void e820__reallocate_tables(void)
744744
* the remaining (if any) entries are passed via the SETUP_E820_EXT node of
745745
* struct setup_data, which is parsed here.
746746
*/
747-
void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
747+
__init void e820__memory_setup_extended(u64 phys_addr, u32 data_len)
748748
{
749749
int entries;
750750
struct boot_e820_entry *extmap;
@@ -773,7 +773,7 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
773773
* This function requires the E820 map to be sorted and without any
774774
* overlapping entries.
775775
*/
776-
void __init e820__register_nosave_regions(unsigned long limit_pfn)
776+
__init void e820__register_nosave_regions(unsigned long limit_pfn)
777777
{
778778
u32 idx;
779779
u64 last_addr = 0;
@@ -798,7 +798,7 @@ void __init e820__register_nosave_regions(unsigned long limit_pfn)
798798
* Register ACPI NVS memory regions, so that we can save/restore them during
799799
* hibernation and the subsequent resume:
800800
*/
801-
static int __init e820__register_nvs_regions(void)
801+
__init static int e820__register_nvs_regions(void)
802802
{
803803
u32 idx;
804804

@@ -822,7 +822,7 @@ core_initcall(e820__register_nvs_regions);
822822
* This allows kexec to fake a new mptable, as if it came from the real
823823
* system.
824824
*/
825-
u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
825+
__init u64 e820__memblock_alloc_reserved(u64 size, u64 align)
826826
{
827827
u64 addr;
828828

@@ -849,7 +849,7 @@ u64 __init e820__memblock_alloc_reserved(u64 size, u64 align)
849849
/*
850850
* Find the highest page frame number we have available
851851
*/
852-
static unsigned long __init e820__end_ram_pfn(unsigned long limit_pfn)
852+
__init static unsigned long e820__end_ram_pfn(unsigned long limit_pfn)
853853
{
854854
u32 idx;
855855
unsigned long last_pfn = 0;
@@ -885,20 +885,20 @@ static unsigned long __init e820__end_ram_pfn(unsigned long limit_pfn)
885885
return last_pfn;
886886
}
887887

888-
unsigned long __init e820__end_of_ram_pfn(void)
888+
__init unsigned long e820__end_of_ram_pfn(void)
889889
{
890890
return e820__end_ram_pfn(MAX_ARCH_PFN);
891891
}
892892

893-
unsigned long __init e820__end_of_low_ram_pfn(void)
893+
__init unsigned long e820__end_of_low_ram_pfn(void)
894894
{
895895
return e820__end_ram_pfn(1UL << (32 - PAGE_SHIFT));
896896
}
897897

898-
static int userdef __initdata;
898+
__initdata static int userdef;
899899

900900
/* The "mem=nopentium" boot option disables 4MB page tables on 32-bit kernels: */
901-
static int __init parse_memopt(char *p)
901+
__init static int parse_memopt(char *p)
902902
{
903903
u64 mem_size;
904904

@@ -932,7 +932,7 @@ static int __init parse_memopt(char *p)
932932
}
933933
early_param("mem", parse_memopt);
934934

935-
static int __init parse_memmap_one(char *p)
935+
__init static int parse_memmap_one(char *p)
936936
{
937937
char *oldp;
938938
u64 start_at, mem_size;
@@ -989,7 +989,7 @@ static int __init parse_memmap_one(char *p)
989989
return *p == '\0' ? 0 : -EINVAL;
990990
}
991991

992-
static int __init parse_memmap_opt(char *str)
992+
__init static int parse_memmap_opt(char *str)
993993
{
994994
while (str) {
995995
char *k = strchr(str, ',');
@@ -1010,7 +1010,7 @@ early_param("memmap", parse_memmap_opt);
10101010
* have been processed, in which case we already have an E820 table filled in
10111011
* via the parameter callback function(s), but it's not sorted and printed yet:
10121012
*/
1013-
void __init e820__finish_early_params(void)
1013+
__init void e820__finish_early_params(void)
10141014
{
10151015
if (userdef) {
10161016
if (e820__update_table(e820_table) < 0)
@@ -1021,7 +1021,7 @@ void __init e820__finish_early_params(void)
10211021
}
10221022
}
10231023

1024-
static const char *__init e820_type_to_string(struct e820_entry *entry)
1024+
__init static const char * e820_type_to_string(struct e820_entry *entry)
10251025
{
10261026
switch (entry->type) {
10271027
case E820_TYPE_RAM: return "System RAM";
@@ -1036,7 +1036,7 @@ static const char *__init e820_type_to_string(struct e820_entry *entry)
10361036
}
10371037
}
10381038

1039-
static unsigned long __init e820_type_to_iomem_type(struct e820_entry *entry)
1039+
__init static unsigned long e820_type_to_iomem_type(struct e820_entry *entry)
10401040
{
10411041
switch (entry->type) {
10421042
case E820_TYPE_RAM: return IORESOURCE_SYSTEM_RAM;
@@ -1051,7 +1051,7 @@ static unsigned long __init e820_type_to_iomem_type(struct e820_entry *entry)
10511051
}
10521052
}
10531053

1054-
static unsigned long __init e820_type_to_iores_desc(struct e820_entry *entry)
1054+
__init static unsigned long e820_type_to_iores_desc(struct e820_entry *entry)
10551055
{
10561056
switch (entry->type) {
10571057
case E820_TYPE_ACPI: return IORES_DESC_ACPI_TABLES;
@@ -1069,13 +1069,13 @@ static unsigned long __init e820_type_to_iores_desc(struct e820_entry *entry)
10691069
/*
10701070
* We assign one resource entry for each E820 map entry:
10711071
*/
1072-
static struct resource __initdata *e820_res;
1072+
__initdata static struct resource *e820_res;
10731073

10741074
/*
10751075
* Is this a device address region that should not be marked busy?
10761076
* (Versus system address regions that we register & lock early.)
10771077
*/
1078-
static bool __init e820_device_region(enum e820_type type, struct resource *res)
1078+
__init static bool e820_device_region(enum e820_type type, struct resource *res)
10791079
{
10801080
/* This is the legacy BIOS/DOS ROM-shadow + MMIO region: */
10811081
if (res->start < (1ULL<<20))
@@ -1104,7 +1104,7 @@ static bool __init e820_device_region(enum e820_type type, struct resource *res)
11041104
/*
11051105
* Mark E820 system regions as busy for the resource manager:
11061106
*/
1107-
void __init e820__reserve_resources(void)
1107+
__init void e820__reserve_resources(void)
11081108
{
11091109
u32 idx;
11101110
struct resource *res;
@@ -1151,7 +1151,7 @@ void __init e820__reserve_resources(void)
11511151
/*
11521152
* How much should we pad the end of RAM, depending on where it is?
11531153
*/
1154-
static unsigned long __init ram_alignment(resource_size_t pos)
1154+
__init static unsigned long ram_alignment(resource_size_t pos)
11551155
{
11561156
unsigned long mb = pos >> 20;
11571157

@@ -1169,7 +1169,7 @@ static unsigned long __init ram_alignment(resource_size_t pos)
11691169

11701170
#define MAX_RESOURCE_SIZE ((resource_size_t)-1)
11711171

1172-
void __init e820__reserve_resources_late(void)
1172+
__init void e820__reserve_resources_late(void)
11731173
{
11741174
u32 idx;
11751175
struct resource *res;
@@ -1219,7 +1219,7 @@ void __init e820__reserve_resources_late(void)
12191219
/*
12201220
* Pass the firmware (bootloader) E820 map to the kernel and process it:
12211221
*/
1222-
char *__init e820__memory_setup_default(void)
1222+
__init char * e820__memory_setup_default(void)
12231223
{
12241224
char *who = "BIOS-e820";
12251225

@@ -1257,7 +1257,7 @@ char *__init e820__memory_setup_default(void)
12571257
* E820 map - with an optional platform quirk available for virtual platforms
12581258
* to override this method of boot environment processing:
12591259
*/
1260-
void __init e820__memory_setup(void)
1260+
__init void e820__memory_setup(void)
12611261
{
12621262
char *who;
12631263

@@ -1273,7 +1273,7 @@ void __init e820__memory_setup(void)
12731273
e820__print_table(who);
12741274
}
12751275

1276-
void __init e820__memblock_setup(void)
1276+
__init void e820__memblock_setup(void)
12771277
{
12781278
u32 idx;
12791279
u64 end;

0 commit comments

Comments
 (0)