Commit d665881d authored by Rob Herring's avatar Rob Herring

of/fdt: Rework early_init_dt_scan_root() to call directly

Use of the of_scan_flat_dt() function predates libfdt and is discouraged
as libfdt provides a nicer set of APIs. Rework early_init_dt_scan_root()
to be called directly and use libfdt.

Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarFrank Rowand <frank.rowand@sony.com>
Link: https://lore.kernel.org/r/20211118181213.1433346-3-robh@kernel.org
parent 60f20d84
...@@ -748,7 +748,7 @@ void __init early_init_devtree(void *params) ...@@ -748,7 +748,7 @@ void __init early_init_devtree(void *params)
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line); of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
/* Scan memory nodes and rebuild MEMBLOCKs */ /* Scan memory nodes and rebuild MEMBLOCKs */
of_scan_flat_dt(early_init_dt_scan_root, NULL); early_init_dt_scan_root();
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
parse_early_param(); parse_early_param();
...@@ -857,7 +857,7 @@ void __init early_get_first_memblock_info(void *params, phys_addr_t *size) ...@@ -857,7 +857,7 @@ void __init early_get_first_memblock_info(void *params, phys_addr_t *size)
* mess the memblock. * mess the memblock.
*/ */
add_mem_to_memblock = 0; add_mem_to_memblock = 0;
of_scan_flat_dt(early_init_dt_scan_root, NULL); early_init_dt_scan_root();
of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
add_mem_to_memblock = 1; add_mem_to_memblock = 1;
......
...@@ -1042,13 +1042,14 @@ int __init early_init_dt_scan_chosen_stdout(void) ...@@ -1042,13 +1042,14 @@ int __init early_init_dt_scan_chosen_stdout(void)
/* /*
* early_init_dt_scan_root - fetch the top level address and size cells * early_init_dt_scan_root - fetch the top level address and size cells
*/ */
int __init early_init_dt_scan_root(unsigned long node, const char *uname, int __init early_init_dt_scan_root(void)
int depth, void *data)
{ {
const __be32 *prop; const __be32 *prop;
const void *fdt = initial_boot_params;
int node = fdt_path_offset(fdt, "/");
if (depth != 0) if (node < 0)
return 0; return -ENODEV;
dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
...@@ -1063,8 +1064,7 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname, ...@@ -1063,8 +1064,7 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,
dt_root_addr_cells = be32_to_cpup(prop); dt_root_addr_cells = be32_to_cpup(prop);
pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells); pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells);
/* break now */ return 0;
return 1;
} }
u64 __init dt_mem_next_cell(int s, const __be32 **cellp) u64 __init dt_mem_next_cell(int s, const __be32 **cellp)
...@@ -1263,7 +1263,7 @@ void __init early_init_dt_scan_nodes(void) ...@@ -1263,7 +1263,7 @@ void __init early_init_dt_scan_nodes(void)
int rc; int rc;
/* Initialize {size,address}-cells info */ /* Initialize {size,address}-cells info */
of_scan_flat_dt(early_init_dt_scan_root, NULL); early_init_dt_scan_root();
/* Retrieve various information from the /chosen node */ /* Retrieve various information from the /chosen node */
rc = early_init_dt_scan_chosen(boot_command_line); rc = early_init_dt_scan_chosen(boot_command_line);
......
...@@ -68,8 +68,7 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size); ...@@ -68,8 +68,7 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size);
extern u64 dt_mem_next_cell(int s, const __be32 **cellp); extern u64 dt_mem_next_cell(int s, const __be32 **cellp);
/* Early flat tree scan hooks */ /* Early flat tree scan hooks */
extern int early_init_dt_scan_root(unsigned long node, const char *uname, extern int early_init_dt_scan_root(void);
int depth, void *data);
extern bool early_init_dt_scan(void *params); extern bool early_init_dt_scan(void *params);
extern bool early_init_dt_verify(void *params); extern bool early_init_dt_verify(void *params);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment