Skip to content

Commit dc1460f

Browse files
bebarinorobherring
authored andcommitted
of: Always unflatten in unflatten_and_copy_device_tree()
We want to populate an empty DT whenever CONFIG_OF is enabled so that overlays can be applied and the DT unit tests can be run. Make unflatten_and_copy_device_tree() stop printing a warning if the 'initial_boot_params' pointer is NULL. Instead, simply copy the dtb if there is one and then unflatten it. If there isn't a DT to copy, then the call to unflatten_device_tree() is largely a no-op, so nothing really changes here. Cc: Rob Herring <robh+dt@kernel.org> Cc: Frank Rowand <frowand.list@gmail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org> Link: https://lore.kernel.org/r/20240217010557.2381548-2-sboyd@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 5d3d723 commit dc1460f

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

drivers/of/fdt.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,21 @@ bool __init early_init_dt_scan(void *params)
13181318
return true;
13191319
}
13201320

1321+
static void *__init copy_device_tree(void *fdt)
1322+
{
1323+
int size;
1324+
void *dt;
1325+
1326+
size = fdt_totalsize(fdt);
1327+
dt = early_init_dt_alloc_memory_arch(size,
1328+
roundup_pow_of_two(FDT_V17_SIZE));
1329+
1330+
if (dt)
1331+
memcpy(dt, fdt, size);
1332+
1333+
return dt;
1334+
}
1335+
13211336
/**
13221337
* unflatten_device_tree - create tree of device_nodes from flat blob
13231338
*
@@ -1350,22 +1365,9 @@ void __init unflatten_device_tree(void)
13501365
*/
13511366
void __init unflatten_and_copy_device_tree(void)
13521367
{
1353-
int size;
1354-
void *dt;
1355-
1356-
if (!initial_boot_params) {
1357-
pr_warn("No valid device tree found, continuing without\n");
1358-
return;
1359-
}
1368+
if (initial_boot_params)
1369+
initial_boot_params = copy_device_tree(initial_boot_params);
13601370

1361-
size = fdt_totalsize(initial_boot_params);
1362-
dt = early_init_dt_alloc_memory_arch(size,
1363-
roundup_pow_of_two(FDT_V17_SIZE));
1364-
1365-
if (dt) {
1366-
memcpy(dt, initial_boot_params, size);
1367-
initial_boot_params = dt;
1368-
}
13691371
unflatten_device_tree();
13701372
}
13711373

0 commit comments

Comments
 (0)