mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
of/reserved_mem: Simplify the logic of fdt_scan_reserved_mem_reg_nodes()
Use the existing helper functions to simplify the logic of fdt_scan_reserved_mem_reg_nodes() Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev> Link: https://patch.msgid.link/20251115134753.179931-8-yuntao.wang@linux.dev Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
This commit is contained in:
committed by
Rob Herring (Arm)
parent
8c0f606831
commit
85a8a30c5b
@@ -225,12 +225,9 @@ static void __init __rmem_check_for_overlap(void);
|
||||
*/
|
||||
void __init fdt_scan_reserved_mem_reg_nodes(void)
|
||||
{
|
||||
int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
|
||||
const void *fdt = initial_boot_params;
|
||||
phys_addr_t base, size;
|
||||
const __be32 *prop;
|
||||
int node, child;
|
||||
int len;
|
||||
|
||||
if (!fdt)
|
||||
return;
|
||||
@@ -251,29 +248,21 @@ void __init fdt_scan_reserved_mem_reg_nodes(void)
|
||||
|
||||
fdt_for_each_subnode(child, fdt, node) {
|
||||
const char *uname;
|
||||
u64 b, s;
|
||||
|
||||
prop = of_get_flat_dt_prop(child, "reg", &len);
|
||||
if (!prop)
|
||||
continue;
|
||||
if (!of_fdt_device_is_available(fdt, child))
|
||||
continue;
|
||||
|
||||
uname = fdt_get_name(fdt, child, NULL);
|
||||
if (len && len % t_len != 0) {
|
||||
pr_err("Reserved memory: invalid reg property in '%s', skipping node.\n",
|
||||
uname);
|
||||
if (!of_flat_dt_get_addr_size(child, "reg", &b, &s))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len > t_len)
|
||||
pr_warn("%s() ignores %d regions in node '%s'\n",
|
||||
__func__, len / t_len - 1, uname);
|
||||
base = b;
|
||||
size = s;
|
||||
|
||||
base = dt_mem_next_cell(dt_root_addr_cells, &prop);
|
||||
size = dt_mem_next_cell(dt_root_size_cells, &prop);
|
||||
|
||||
if (size)
|
||||
if (size) {
|
||||
uname = fdt_get_name(fdt, child, NULL);
|
||||
fdt_reserved_mem_save_node(child, uname, base, size);
|
||||
}
|
||||
}
|
||||
|
||||
/* check for overlapping reserved regions */
|
||||
|
||||
Reference in New Issue
Block a user