[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240112200750.4062441-4-sboyd@kernel.org>
Date: Fri, 12 Jan 2024 12:07:46 -0800
From: Stephen Boyd <sboyd@...nel.org>
To: Rob Herring <robh+dt@...nel.org>
Cc: linux-kernel@...r.kernel.org,
patches@...ts.linux.dev,
linux-um@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org,
kunit-dev@...glegroups.com,
linux-kselftest@...r.kernel.org,
devicetree@...r.kernel.org,
Frank Rowand <frowand.list@...il.com>
Subject: [PATCH 3/6] 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@...nel.org>
Cc: Frank Rowand <frowand.list@...il.com>
Signed-off-by: Stephen Boyd <sboyd@...nel.org>
---
drivers/of/fdt.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bf502ba8da95..b488ad86d456 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1318,6 +1318,21 @@ bool __init early_init_dt_scan(void *params)
return true;
}
+static void __init copy_device_tree(void)
+{
+ int size;
+ void *dt;
+
+ size = fdt_totalsize(initial_boot_params);
+ dt = early_init_dt_alloc_memory_arch(size,
+ roundup_pow_of_two(FDT_V17_SIZE));
+
+ if (dt) {
+ memcpy(dt, initial_boot_params, size);
+ initial_boot_params = dt;
+ }
+}
+
/**
* unflatten_device_tree - create tree of device_nodes from flat blob
*
@@ -1350,22 +1365,9 @@ void __init unflatten_device_tree(void)
*/
void __init unflatten_and_copy_device_tree(void)
{
- int size;
- void *dt;
+ if (initial_boot_params)
+ copy_device_tree();
- if (!initial_boot_params) {
- pr_warn("No valid device tree found, continuing without\n");
- return;
- }
-
- size = fdt_totalsize(initial_boot_params);
- dt = early_init_dt_alloc_memory_arch(size,
- roundup_pow_of_two(FDT_V17_SIZE));
-
- if (dt) {
- memcpy(dt, initial_boot_params, size);
- initial_boot_params = dt;
- }
unflatten_device_tree();
}
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
Powered by blists - more mailing lists