devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Suchanek <hramrach@gmail.com>
To: Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Michal Suchanek <hramrach@gmail.com>
Subject: [PATCH 2/2] of: fdt: mark unflattened tree as detached
Date: Sun, 26 Jun 2016 22:11:59 +0200	[thread overview]
Message-ID: <01da4c372750e6618638a0320e7ea2f656da3ae5.1466971467.git.hramrach@gmail.com> (raw)
In-Reply-To: <cover.1466971467.git.hramrach@gmail.com>
In-Reply-To: <cover.1466971467.git.hramrach@gmail.com>

The tree returned from of_fdt_unflatten_tree cannot be attached to the
live tree because it is not marked as detached so mark it as such. The
dt resolver checks the flag and refuses to process the tree otherwise.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
---
 drivers/of/fdt.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3349d2a..7b075cf 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -384,7 +384,8 @@ static void * unflatten_dt_node(const void *blob,
  */
 static void __unflatten_device_tree(const void *blob,
 			     struct device_node **mynodes,
-			     void * (*dt_alloc)(u64 size, u64 align))
+			     void * (*dt_alloc)(u64 size, u64 align),
+			     bool detached)
 {
 	unsigned long size;
 	int start;
@@ -428,6 +429,10 @@ static void __unflatten_device_tree(const void *blob,
 	if (be32_to_cpup(mem + size) != 0xdeadbeef)
 		pr_warning("End of tree marker overwritten: %08x\n",
 			   be32_to_cpup(mem + size));
+	if (detached) {
+		of_node_set_flag(*mynodes, OF_DETACHED);
+		pr_debug("unflattened tree is detached\n");
+	}
 
 	pr_debug(" <- unflatten_device_tree()\n");
 }
@@ -451,7 +456,7 @@ void of_fdt_unflatten_tree(const unsigned long *blob,
 			struct device_node **mynodes)
 {
 	mutex_lock(&of_fdt_unflatten_mutex);
-	__unflatten_device_tree(blob, mynodes, &kernel_tree_alloc);
+	__unflatten_device_tree(blob, mynodes, &kernel_tree_alloc, true);
 	mutex_unlock(&of_fdt_unflatten_mutex);
 }
 EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
@@ -1119,7 +1124,8 @@ bool __init early_init_dt_scan(void *params)
 void __init unflatten_device_tree(void)
 {
 	__unflatten_device_tree(initial_boot_params, &of_root,
-				early_init_dt_alloc_memory_arch);
+				early_init_dt_alloc_memory_arch,
+				false);
 
 	/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
 	of_alias_scan(early_init_dt_alloc_memory_arch);
-- 
2.8.1

  parent reply	other threads:[~2016-06-26 20:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26 20:11 [PATCH 0/2] devicetree overlay small fixes Michal Suchanek
     [not found] ` <cover.1466971467.git.hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-26 20:11   ` [PATCH 1/2] of: overlay: add resolver error prints Michal Suchanek
     [not found]     ` <38852c55a0da4780b64a8248e16df73a1d54891e.1466971467.git.hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-18 21:47       ` Rob Herring
2016-06-26 20:11 ` Michal Suchanek [this message]
     [not found]   ` <01da4c372750e6618638a0320e7ea2f656da3ae5.1466971467.git.hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-18 21:44     ` [PATCH 2/2] of: fdt: mark unflattened tree as detached Rob Herring
     [not found]       ` <CAL_JsqLiFYbcqj__B+WB7Q4=MCsr0NOwg4BpRqg1GH+=gadsVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-18 22:01         ` [PATCH] " Michal Suchanek
2016-07-22 19:55           ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01da4c372750e6618638a0320e7ea2f656da3ae5.1466971467.git.hramrach@gmail.com \
    --to=hramrach@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).