diff options
author | Tejun Heo <tj@kernel.org> | 2011-12-08 13:22:07 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-12-08 13:22:07 -0500 |
commit | fe091c208a40299fba40e62292a610fb91e44b4e (patch) | |
tree | 72bf673f05a736cbf3555a4dcf428b95840fc9f7 | |
parent | c5a1cb284b791fcc3c70962331a682452afaf6cd (diff) |
memblock: Kill memblock_init()
memblock_init() initializes arrays for regions and memblock itself;
however, all these can be done with struct initializers and
memblock_init() can be removed. This patch kills memblock_init() and
initializes memblock with struct initializer.
The only difference is that the first dummy entries don't have .nid
set to MAX_NUMNODES initially. This doesn't cause any behavior
difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: "H. Peter Anvin" <hpa@zytor.com>
-rw-r--r-- | arch/arm/mm/init.c | 1 | ||||
-rw-r--r-- | arch/microblaze/kernel/prom.c | 1 | ||||
-rw-r--r-- | arch/openrisc/kernel/prom.c | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom.c | 2 | ||||
-rw-r--r-- | arch/sh/mm/init.c | 1 | ||||
-rw-r--r-- | arch/sparc/mm/init_64.c | 2 | ||||
-rw-r--r-- | arch/unicore32/mm/init.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/head32.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/head64.c | 2 | ||||
-rw-r--r-- | arch/x86/xen/enlighten.c | 2 | ||||
-rw-r--r-- | include/linux/memblock.h | 1 | ||||
-rw-r--r-- | mm/memblock.c | 48 |
12 files changed, 14 insertions, 50 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 9863f03097d0..4140843399ca 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -333,7 +333,6 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) | |||
333 | 333 | ||
334 | sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); | 334 | sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); |
335 | 335 | ||
336 | memblock_init(); | ||
337 | for (i = 0; i < mi->nr_banks; i++) | 336 | for (i = 0; i < mi->nr_banks; i++) |
338 | memblock_add(mi->bank[i].start, mi->bank[i].size); | 337 | memblock_add(mi->bank[i].start, mi->bank[i].size); |
339 | 338 | ||
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index 977484add216..4d65e9721f60 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c | |||
@@ -122,7 +122,6 @@ void __init early_init_devtree(void *params) | |||
122 | of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line); | 122 | of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line); |
123 | 123 | ||
124 | /* Scan memory nodes and rebuild MEMBLOCKs */ | 124 | /* Scan memory nodes and rebuild MEMBLOCKs */ |
125 | memblock_init(); | ||
126 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 125 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
127 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); | 126 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); |
128 | 127 | ||
diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c index 1bb58ba89afa..7dbc6e090b81 100644 --- a/arch/openrisc/kernel/prom.c +++ b/arch/openrisc/kernel/prom.c | |||
@@ -76,7 +76,6 @@ void __init early_init_devtree(void *params) | |||
76 | of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line); | 76 | of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line); |
77 | 77 | ||
78 | /* Scan memory nodes and rebuild MEMBLOCKs */ | 78 | /* Scan memory nodes and rebuild MEMBLOCKs */ |
79 | memblock_init(); | ||
80 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 79 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
81 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); | 80 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); |
82 | 81 | ||
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index fa1235b0503b..a7ee83e6eb17 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -733,8 +733,6 @@ void __init early_init_devtree(void *params) | |||
733 | of_scan_flat_dt(early_init_dt_scan_chosen_ppc, cmd_line); | 733 | of_scan_flat_dt(early_init_dt_scan_chosen_ppc, cmd_line); |
734 | 734 | ||
735 | /* Scan memory nodes and rebuild MEMBLOCKs */ | 735 | /* Scan memory nodes and rebuild MEMBLOCKs */ |
736 | memblock_init(); | ||
737 | |||
738 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 736 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
739 | of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); | 737 | of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); |
740 | 738 | ||
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 939ca0f356f6..2528962609f8 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
@@ -324,7 +324,6 @@ void __init paging_init(void) | |||
324 | unsigned long vaddr, end; | 324 | unsigned long vaddr, end; |
325 | int nid; | 325 | int nid; |
326 | 326 | ||
327 | memblock_init(); | ||
328 | sh_mv.mv_mem_init(); | 327 | sh_mv.mv_mem_init(); |
329 | 328 | ||
330 | early_reserve_mem(); | 329 | early_reserve_mem(); |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 8584a25a9f0d..f42cc878bf97 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -1769,8 +1769,6 @@ void __init paging_init(void) | |||
1769 | sun4v_ktsb_init(); | 1769 | sun4v_ktsb_init(); |
1770 | } | 1770 | } |
1771 | 1771 | ||
1772 | memblock_init(); | ||
1773 | |||
1774 | /* Find available physical memory... | 1772 | /* Find available physical memory... |
1775 | * | 1773 | * |
1776 | * Read it twice in order to work around a bug in openfirmware. | 1774 | * Read it twice in order to work around a bug in openfirmware. |
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c index 5fb09e2e5d0e..01e235bd669d 100644 --- a/arch/unicore32/mm/init.c +++ b/arch/unicore32/mm/init.c | |||
@@ -246,7 +246,6 @@ void __init uc32_memblock_init(struct meminfo *mi) | |||
246 | sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), | 246 | sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), |
247 | meminfo_cmp, NULL); | 247 | meminfo_cmp, NULL); |
248 | 248 | ||
249 | memblock_init(); | ||
250 | for (i = 0; i < mi->nr_banks; i++) | 249 | for (i = 0; i < mi->nr_banks; i++) |
251 | memblock_add(mi->bank[i].start, mi->bank[i].size); | 250 | memblock_add(mi->bank[i].start, mi->bank[i].size); |
252 | 251 | ||
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index be9282bcda72..51ff18616d50 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c | |||
@@ -31,8 +31,6 @@ static void __init i386_default_early_setup(void) | |||
31 | 31 | ||
32 | void __init i386_start_kernel(void) | 32 | void __init i386_start_kernel(void) |
33 | { | 33 | { |
34 | memblock_init(); | ||
35 | |||
36 | memblock_reserve(__pa_symbol(&_text), | 34 | memblock_reserve(__pa_symbol(&_text), |
37 | __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); | 35 | __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); |
38 | 36 | ||
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index fd25b11549b8..3a3b779f41d3 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
@@ -98,8 +98,6 @@ void __init x86_64_start_reservations(char *real_mode_data) | |||
98 | { | 98 | { |
99 | copy_bootdata(__va(real_mode_data)); | 99 | copy_bootdata(__va(real_mode_data)); |
100 | 100 | ||
101 | memblock_init(); | ||
102 | |||
103 | memblock_reserve(__pa_symbol(&_text), | 101 | memblock_reserve(__pa_symbol(&_text), |
104 | __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); | 102 | __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); |
105 | 103 | ||
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 1f928659c338..12eb07bfb267 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -1215,8 +1215,6 @@ asmlinkage void __init xen_start_kernel(void) | |||
1215 | local_irq_disable(); | 1215 | local_irq_disable(); |
1216 | early_boot_irqs_disabled = true; | 1216 | early_boot_irqs_disabled = true; |
1217 | 1217 | ||
1218 | memblock_init(); | ||
1219 | |||
1220 | xen_raw_console_write("mapping kernel into physical memory\n"); | 1218 | xen_raw_console_write("mapping kernel into physical memory\n"); |
1221 | pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); | 1219 | pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); |
1222 | xen_ident_map_ISA(); | 1220 | xen_ident_map_ISA(); |
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 1a3bee78590f..6ac91c5b2fd3 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h | |||
@@ -52,7 +52,6 @@ phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, | |||
52 | int memblock_free_reserved_regions(void); | 52 | int memblock_free_reserved_regions(void); |
53 | int memblock_reserve_reserved_regions(void); | 53 | int memblock_reserve_reserved_regions(void); |
54 | 54 | ||
55 | void memblock_init(void); | ||
56 | void memblock_analyze(void); | 55 | void memblock_analyze(void); |
57 | int memblock_add(phys_addr_t base, phys_addr_t size); | 56 | int memblock_add(phys_addr_t base, phys_addr_t size); |
58 | int memblock_remove(phys_addr_t base, phys_addr_t size); | 57 | int memblock_remove(phys_addr_t base, phys_addr_t size); |
diff --git a/mm/memblock.c b/mm/memblock.c index e808df845bbb..5bbb87f59aee 100644 --- a/mm/memblock.c +++ b/mm/memblock.c | |||
@@ -20,12 +20,23 @@ | |||
20 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
21 | #include <linux/memblock.h> | 21 | #include <linux/memblock.h> |
22 | 22 | ||
23 | struct memblock memblock __initdata_memblock; | 23 | static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; |
24 | static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; | ||
25 | |||
26 | struct memblock memblock __initdata_memblock = { | ||
27 | .memory.regions = memblock_memory_init_regions, | ||
28 | .memory.cnt = 1, /* empty dummy entry */ | ||
29 | .memory.max = INIT_MEMBLOCK_REGIONS, | ||
30 | |||
31 | .reserved.regions = memblock_reserved_init_regions, | ||
32 | .reserved.cnt = 1, /* empty dummy entry */ | ||
33 | .reserved.max = INIT_MEMBLOCK_REGIONS, | ||
34 | |||
35 | .current_limit = MEMBLOCK_ALLOC_ANYWHERE, | ||
36 | }; | ||
24 | 37 | ||
25 | int memblock_debug __initdata_memblock; | 38 | int memblock_debug __initdata_memblock; |
26 | int memblock_can_resize __initdata_memblock; | 39 | int memblock_can_resize __initdata_memblock; |
27 | static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; | ||
28 | static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; | ||
29 | 40 | ||
30 | /* inline so we don't get a warning when pr_debug is compiled out */ | 41 | /* inline so we don't get a warning when pr_debug is compiled out */ |
31 | static inline const char *memblock_type_name(struct memblock_type *type) | 42 | static inline const char *memblock_type_name(struct memblock_type *type) |
@@ -920,37 +931,6 @@ void __init memblock_analyze(void) | |||
920 | memblock_can_resize = 1; | 931 | memblock_can_resize = 1; |
921 | } | 932 | } |
922 | 933 | ||
923 | void __init memblock_init(void) | ||
924 | { | ||
925 | static int init_done __initdata = 0; | ||
926 | |||
927 | if (init_done) | ||
928 | return; | ||
929 | init_done = 1; | ||
930 | |||
931 | /* Hookup the initial arrays */ | ||
932 | memblock.memory.regions = memblock_memory_init_regions; | ||
933 | memblock.memory.max = INIT_MEMBLOCK_REGIONS; | ||
934 | memblock.reserved.regions = memblock_reserved_init_regions; | ||
935 | memblock.reserved.max = INIT_MEMBLOCK_REGIONS; | ||
936 | |||
937 | /* Create a dummy zero size MEMBLOCK which will get coalesced away later. | ||
938 | * This simplifies the memblock_add() code below... | ||
939 | */ | ||
940 | memblock.memory.regions[0].base = 0; | ||
941 | memblock.memory.regions[0].size = 0; | ||
942 | memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES); | ||
943 | memblock.memory.cnt = 1; | ||
944 | |||
945 | /* Ditto. */ | ||
946 | memblock.reserved.regions[0].base = 0; | ||
947 | memblock.reserved.regions[0].size = 0; | ||
948 | memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES); | ||
949 | memblock.reserved.cnt = 1; | ||
950 | |||
951 | memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE; | ||
952 | } | ||
953 | |||
954 | static int __init early_memblock(char *p) | 934 | static int __init early_memblock(char *p) |
955 | { | 935 | { |
956 | if (p && strstr(p, "debug")) | 936 | if (p && strstr(p, "debug")) |