of/fdt: use memblock_virt_alloc for early alloc

memblock_virt_alloc() works for both memblock and bootmem, so use it and
make early_init_dt_alloc_memory_arch a static function. The arches using
bootmem define early_init_dt_alloc_memory_arch as either:

__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))

or:

alloc_bootmem_align(size, align)

Both of these evaluate to the same thing as does memblock_virt_alloc for
bootmem. So we can disable the arch specific functions by making
early_init_dt_alloc_memory_arch static and they can be removed in
subsequent commits.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:
Rob Herring
2018-01-05 15:32:33 -06:00
parent af6074fc9a
commit 0fa1c57934
3 changed files with 14 additions and 18 deletions

View File

@@ -5,6 +5,7 @@
#define pr_fmt(fmt) "### dt-test ### " fmt
#include <linux/bootmem.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/errno.h>
@@ -2053,6 +2054,11 @@ static struct overlay_info overlays[] = {
static struct device_node *overlay_base_root;
static void * __init dt_alloc_memory(u64 size, u64 align)
{
return memblock_virt_alloc(size, align);
}
/*
* Create base device tree for the overlay unittest.
*
@@ -2092,8 +2098,7 @@ void __init unittest_unflatten_overlay_base(void)
return;
}
info->data = early_init_dt_alloc_memory_arch(size,
roundup_pow_of_two(FDT_V17_SIZE));
info->data = dt_alloc_memory(size, roundup_pow_of_two(FDT_V17_SIZE));
if (!info->data) {
pr_err("alloc for dtb 'overlay_base' failed");
return;
@@ -2102,7 +2107,7 @@ void __init unittest_unflatten_overlay_base(void)
memcpy(info->data, info->dtb_begin, size);
__unflatten_device_tree(info->data, NULL, &info->np_overlay,
early_init_dt_alloc_memory_arch, true);
dt_alloc_memory, true);
overlay_base_root = info->np_overlay;
}