Skip to content

Commit a1727da

Browse files
committed
of: consolidate definition of early_init_dt_alloc_memory_arch()
Most architectures use the same implementation. Collapse the common ones into a single weak function that can be overridden. Signed-off-by: Grant Likely <grant.likely@linaro.org>
1 parent 7e0bdf1 commit a1727da

7 files changed

Lines changed: 12 additions & 31 deletions

File tree

‎arch/arc/kernel/devtree.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#include <asm/clk.h>
1919
#include <asm/mach_desc.h>
2020

21-
/* called from unflatten_device_tree() to bootstrap devicetree itself */
22-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
23-
{
24-
return __va(memblock_alloc(size, align));
25-
}
26-
2721
/**
2822
* setup_machine_fdt - Machine setup when an dtb was passed to the kernel
2923
* @dt: virtual address pointer to dt blob

‎arch/arm64/kernel/setup.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
190190
memblock_add(base, size);
191191
}
192192

193-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
194-
{
195-
return __va(memblock_alloc(size, align));
196-
}
197-
198193
/*
199194
* Limit the memory size that was specified via FDT.
200195
*/

‎arch/c6x/kernel/devicetree.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,3 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4545
{
4646
c6x_add_memory(base, size);
4747
}
48-
49-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
50-
{
51-
return __va(memblock_alloc(size, align));
52-
}

‎arch/microblaze/kernel/prom.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4646
memblock_add(base, size);
4747
}
4848

49-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
50-
{
51-
return __va(memblock_alloc(size, align));
52-
}
53-
5449
#ifdef CONFIG_EARLY_PRINTK
5550
static char *stdout;
5651

‎arch/openrisc/kernel/prom.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
5555
memblock_add(base, size);
5656
}
5757

58-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
59-
{
60-
return __va(memblock_alloc(size, align));
61-
}
62-
6358
void __init early_init_devtree(void *params)
6459
{
6560
void *alloc;

‎arch/powerpc/kernel/prom.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
544544
memblock_add(base, size);
545545
}
546546

547-
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
548-
{
549-
return __va(memblock_alloc(size, align));
550-
}
551-
552547
#ifdef CONFIG_BLK_DEV_INITRD
553548
void __init early_init_dt_setup_initrd_arch(u64 start, u64 end)
554549
{

‎drivers/of/fdt.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <linux/kernel.h>
1313
#include <linux/initrd.h>
14+
#include <linux/memblock.h>
1415
#include <linux/module.h>
1516
#include <linux/of.h>
1617
#include <linux/of_fdt.h>
@@ -700,6 +701,17 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
700701
return 1;
701702
}
702703

704+
#ifdef CONFIG_HAVE_MEMBLOCK
705+
/*
706+
* called from unflatten_device_tree() to bootstrap devicetree itself
707+
* Architectures can override this definition if memblock isn't used
708+
*/
709+
void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)
710+
{
711+
return __va(memblock_alloc(size, align));
712+
}
713+
#endif
714+
703715
/**
704716
* unflatten_device_tree - create tree of device_nodes from flat blob
705717
*

0 commit comments

Comments
 (0)