From: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
Daniel Drake <dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 2/3] of/promtree: switch to building the DT using of_attach_node
Date: Wed, 9 Mar 2011 16:16:06 -0800 [thread overview]
Message-ID: <1299716167-9656-3-git-send-email-dilinger@queued.net> (raw)
In-Reply-To: <1299716167-9656-1-git-send-email-dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
Use common functions (of_attach_node) to build the device tree. This
allows us to drop a bit of code, and provides a more understandable
tree building. It does change the order of the allnodes/allnext list;
the old tree looked something like this:
allnodes --> root (/)
allnext ------> np1 (/pci)
allnext --> np2 (/pci/foo)
allnext=NULL
Pretend that was a tree. The new tree looks something like this:
allnodes root (/)
| allnext=NULL np1 (/pci)
| ^------------ allnext np2 (/pci/foo)
| ^-------- allnext
|_____________________________________^
That shouldn't actually matter for anything, but it's worth noting in case
anyone notices odd behavior changes. Plus, it's a good excuse to make
beautiful art.
Also note that this changes what gets passed to the of_pdt_build_more()
hook. The only user of this hook is sparc's leon_kernel.c, which ends
up using it to call prom_amba_init. However, prom_amba_init isn't
actually set in the kernel, so I can't tell whether this actually breaks
behavior or not.
Signed-off-by: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
---
drivers/of/pdt.c | 39 ++++++++++++---------------------------
1 files changed, 12 insertions(+), 27 deletions(-)
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
index 4d87b5d..5933127 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -193,56 +193,41 @@ static struct device_node * __init of_pdt_create_node(phandle node,
return dp;
}
-static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
- phandle node,
- struct device_node ***nextp)
+static void __init of_pdt_build_tree(struct device_node *parent, phandle node)
{
- struct device_node *ret = NULL, *prev_sibling = NULL;
struct device_node *dp;
- while (1) {
+ while (node) {
dp = of_pdt_create_node(node, parent);
if (!dp)
break;
- if (prev_sibling)
- prev_sibling->sibling = dp;
-
- if (!ret)
- ret = dp;
- prev_sibling = dp;
-
- *(*nextp) = dp;
- *nextp = &dp->allnext;
-
dp->full_name = of_pdt_build_full_name(dp);
+ of_attach_node(dp);
- dp->child = of_pdt_build_tree(dp,
- of_pdt_prom_ops->getchild(node), nextp);
+ /* process child nodes prior to siblings */
+ of_pdt_build_tree(dp, of_pdt_prom_ops->getchild(node));
if (of_pdt_build_more)
- of_pdt_build_more(dp, nextp);
+ of_pdt_build_more(dp, NULL);
node = of_pdt_prom_ops->getsibling(node);
}
-
- return ret;
}
void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops)
{
- struct device_node **nextp;
+ struct device_node *dp;
BUG_ON(!ops);
of_pdt_prom_ops = ops;
- allnodes = of_pdt_create_node(root_node, NULL);
+ dp = of_pdt_create_node(root_node, NULL);
#if defined(CONFIG_SPARC)
- allnodes->path_component_name = "";
+ dp->path_component_name = "";
#endif
- allnodes->full_name = "/";
+ dp->full_name = "/";
- nextp = &allnodes->allnext;
- allnodes->child = of_pdt_build_tree(allnodes,
- of_pdt_prom_ops->getchild(allnodes->phandle), &nextp);
+ of_attach_node(dp);
+ of_pdt_build_tree(dp, of_pdt_prom_ops->getchild(dp->phandle));
}
--
1.7.2.3
next prev parent reply other threads:[~2011-03-10 0:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-10 0:16 [PATCH 0/3] switch DT creation to using of_attach_node Andres Salomon
[not found] ` <1299716167-9656-1-git-send-email-dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
2011-03-10 0:16 ` [PATCH 1/3] of: remove OF_DYNAMIC config option Andres Salomon
[not found] ` <1299716167-9656-2-git-send-email-dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
2011-03-12 9:00 ` Grant Likely
2011-03-10 0:16 ` Andres Salomon [this message]
2011-03-12 9:00 ` [PATCH 2/3] of/promtree: switch to building the DT using of_attach_node Grant Likely
2011-03-10 0:16 ` [PATCH 3/3] of/flattree: use of_attach_node to build tree, and associated cleanups Andres Salomon
[not found] ` <1299716167-9656-4-git-send-email-dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
2011-03-12 9:10 ` Grant Likely
[not found] ` <20110312091056.GG9347-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-03-12 19:37 ` Andres Salomon
[not found] ` <20110312113726.0bf060da-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
2011-03-15 3:34 ` Grant Likely
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=1299716167-9656-3-git-send-email-dilinger@queued.net \
--to=dilinger-pffuokh25lwstnjn9+bgxg@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
--cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sparclinux-u79uwXL29TY76Z2rM5mHXA@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).