devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Suchanek <hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Michal Suchanek <hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH] of: fdt: mark unflattened tree as detached
Date: Tue, 19 Jul 2016 00:01:12 +0200	[thread overview]
Message-ID: <12088f6fd9a39fc28f6756ec4c1ba034b9a37f0b.1468879073.git.hramrach@gmail.com> (raw)
In-Reply-To: <CAL_JsqLiFYbcqj__B+WB7Q4=MCsr0NOwg4BpRqg1GH+=gadsVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 - rebase on top of 4.7rc
---
 drivers/of/fdt.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 33daffc..f5c802d 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -472,7 +472,8 @@ static int unflatten_dt_nodes(const void *blob,
 static void *__unflatten_device_tree(const void *blob,
 				     struct device_node *dad,
 				     struct device_node **mynodes,
-				     void *(*dt_alloc)(u64 size, u64 align))
+				     void *(*dt_alloc)(u64 size, u64 align),
+				     bool detached)
 {
 	int size;
 	void *mem;
@@ -516,6 +517,11 @@ static void *__unflatten_device_tree(const void *blob,
 		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");
 	return mem;
 }
@@ -548,7 +554,8 @@ void *of_fdt_unflatten_tree(const unsigned long *blob,
 	void *mem;
 
 	mutex_lock(&of_fdt_unflatten_mutex);
-	mem = __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
+	mem = __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc,
+				      true);
 	mutex_unlock(&of_fdt_unflatten_mutex);
 
 	return mem;
@@ -1224,7 +1231,7 @@ bool __init early_init_dt_scan(void *params)
 void __init unflatten_device_tree(void)
 {
 	__unflatten_device_tree(initial_boot_params, NULL, &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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-07-18 22:01 UTC|newest]

Thread overview: 8+ 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 ` [PATCH 2/2] of: fdt: mark unflattened tree as detached Michal Suchanek
     [not found]   ` <01da4c372750e6618638a0320e7ea2f656da3ae5.1466971467.git.hramrach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-18 21:44     ` Rob Herring
     [not found]       ` <CAL_JsqLiFYbcqj__B+WB7Q4=MCsr0NOwg4BpRqg1GH+=gadsVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-18 22:01         ` Michal Suchanek [this message]
2016-07-22 19:55           ` [PATCH] " Rob Herring
  -- strict thread matches above, loose matches on Subject: below --
2015-05-06 22:53 Michal Suchanek

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=12088f6fd9a39fc28f6756ec4c1ba034b9a37f0b.1468879073.git.hramrach@gmail.com \
    --to=hramrach-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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).