memblock: Kill memblock_init()
authorTejun Heo <tj@kernel.org>
Thu, 8 Dec 2011 18:22:07 +0000 (10:22 -0800)
committerTejun Heo <tj@kernel.org>
Thu, 8 Dec 2011 18:22:07 +0000 (10:22 -0800)
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>

12 files changed:
arch/arm/mm/init.c
arch/microblaze/kernel/prom.c
arch/openrisc/kernel/prom.c
arch/powerpc/kernel/prom.c
arch/sh/mm/init.c
arch/sparc/mm/init_64.c
arch/unicore32/mm/init.c
arch/x86/kernel/head32.c
arch/x86/kernel/head64.c
arch/x86/xen/enlighten.c
include/linux/memblock.h
mm/memblock.c

index 9863f03..4140843 100644 (file)
@@ -333,7 +333,6 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
 
        sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
 
-       memblock_init();
        for (i = 0; i < mi->nr_banks; i++)
                memblock_add(mi->bank[i].start, mi->bank[i].size);
 
index 977484a..4d65e97 100644 (file)
@@ -122,7 +122,6 @@ void __init early_init_devtree(void *params)
        of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
 
        /* Scan memory nodes and rebuild MEMBLOCKs */
-       memblock_init();
        of_scan_flat_dt(early_init_dt_scan_root, NULL);
        of_scan_flat_dt(early_init_dt_scan_memory, NULL);
 
index 1bb58ba..7dbc6e0 100644 (file)
@@ -76,7 +76,6 @@ void __init early_init_devtree(void *params)
        of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
 
        /* Scan memory nodes and rebuild MEMBLOCKs */
-       memblock_init();
        of_scan_flat_dt(early_init_dt_scan_root, NULL);
        of_scan_flat_dt(early_init_dt_scan_memory, NULL);
 
index fa1235b..a7ee83e 100644 (file)
@@ -733,8 +733,6 @@ void __init early_init_devtree(void *params)
        of_scan_flat_dt(early_init_dt_scan_chosen_ppc, cmd_line);
 
        /* Scan memory nodes and rebuild MEMBLOCKs */
-       memblock_init();
-
        of_scan_flat_dt(early_init_dt_scan_root, NULL);
        of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
 
index 939ca0f..2528962 100644 (file)
@@ -324,7 +324,6 @@ void __init paging_init(void)
        unsigned long vaddr, end;
        int nid;
 
-       memblock_init();
        sh_mv.mv_mem_init();
 
        early_reserve_mem();
index 8584a25..f42cc87 100644 (file)
@@ -1769,8 +1769,6 @@ void __init paging_init(void)
                sun4v_ktsb_init();
        }
 
-       memblock_init();
-
        /* Find available physical memory...
         *
         * Read it twice in order to work around a bug in openfirmware.
index 5fb09e2..01e235b 100644 (file)
@@ -246,7 +246,6 @@ void __init uc32_memblock_init(struct meminfo *mi)
        sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]),
                meminfo_cmp, NULL);
 
-       memblock_init();
        for (i = 0; i < mi->nr_banks; i++)
                memblock_add(mi->bank[i].start, mi->bank[i].size);
 
index be9282b..51ff186 100644 (file)
@@ -31,8 +31,6 @@ static void __init i386_default_early_setup(void)
 
 void __init i386_start_kernel(void)
 {
-       memblock_init();
-
        memblock_reserve(__pa_symbol(&_text),
                         __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
index fd25b11..3a3b779 100644 (file)
@@ -98,8 +98,6 @@ void __init x86_64_start_reservations(char *real_mode_data)
 {
        copy_bootdata(__va(real_mode_data));
 
-       memblock_init();
-
        memblock_reserve(__pa_symbol(&_text),
                         __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
index 1f92865..12eb07b 100644 (file)
@@ -1215,8 +1215,6 @@ asmlinkage void __init xen_start_kernel(void)
        local_irq_disable();
        early_boot_irqs_disabled = true;
 
-       memblock_init();
-
        xen_raw_console_write("mapping kernel into physical memory\n");
        pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages);
        xen_ident_map_ISA();
index 1a3bee7..6ac91c5 100644 (file)
@@ -52,7 +52,6 @@ phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
 int memblock_free_reserved_regions(void);
 int memblock_reserve_reserved_regions(void);
 
-void memblock_init(void);
 void memblock_analyze(void);
 int memblock_add(phys_addr_t base, phys_addr_t size);
 int memblock_remove(phys_addr_t base, phys_addr_t size);
index e808df8..5bbb87f 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/memblock.h>
 
-struct memblock memblock __initdata_memblock;
+static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
+static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
+
+struct memblock memblock __initdata_memblock = {
+       .memory.regions         = memblock_memory_init_regions,
+       .memory.cnt             = 1,    /* empty dummy entry */
+       .memory.max             = INIT_MEMBLOCK_REGIONS,
+
+       .reserved.regions       = memblock_reserved_init_regions,
+       .reserved.cnt           = 1,    /* empty dummy entry */
+       .reserved.max           = INIT_MEMBLOCK_REGIONS,
+
+       .current_limit          = MEMBLOCK_ALLOC_ANYWHERE,
+};
 
 int memblock_debug __initdata_memblock;
 int memblock_can_resize __initdata_memblock;
-static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
-static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
 
 /* inline so we don't get a warning when pr_debug is compiled out */
 static inline const char *memblock_type_name(struct memblock_type *type)
@@ -920,37 +931,6 @@ void __init memblock_analyze(void)
        memblock_can_resize = 1;
 }
 
-void __init memblock_init(void)
-{
-       static int init_done __initdata = 0;
-
-       if (init_done)
-               return;
-       init_done = 1;
-
-       /* Hookup the initial arrays */
-       memblock.memory.regions = memblock_memory_init_regions;
-       memblock.memory.max             = INIT_MEMBLOCK_REGIONS;
-       memblock.reserved.regions       = memblock_reserved_init_regions;
-       memblock.reserved.max   = INIT_MEMBLOCK_REGIONS;
-
-       /* Create a dummy zero size MEMBLOCK which will get coalesced away later.
-        * This simplifies the memblock_add() code below...
-        */
-       memblock.memory.regions[0].base = 0;
-       memblock.memory.regions[0].size = 0;
-       memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES);
-       memblock.memory.cnt = 1;
-
-       /* Ditto. */
-       memblock.reserved.regions[0].base = 0;
-       memblock.reserved.regions[0].size = 0;
-       memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES);
-       memblock.reserved.cnt = 1;
-
-       memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
-}
-
 static int __init early_memblock(char *p)
 {
        if (p && strstr(p, "debug"))