path: root/drivers/of/dynamic.c
diff options
authorGrant Likely <grant.likely@linaro.org>2014-07-15 23:25:43 -0600
committerMark Brown <broonie@kernel.org>2015-02-19 22:42:30 +0900
commit915ec64e24a02a4562c855376ce7b4abb8bf558d (patch)
treeaecd7a7575a928fb9347e515f1bfbf0332ef5783 /drivers/of/dynamic.c
parentf0122c35d9071b50a79833bd227b9b0537c0ee07 (diff)
of: Move dynamic node fixups out of powerpc and into common code
PowerPC does an odd thing with dynamic nodes. It uses a notifier to catch new node additions and set some of the values like name and type. This makes no sense since that same code can be put directly into of_attach_node(). Besides, all dynamic node users need this, not just powerpc. Fix this problem by moving the logic out of arch/powerpc and into drivers/of/dynamic.c. It is also important to remove this notifier because we want to move the firing of notifiers from before the tree is modified to after so that the receiver gets a consistent view of the tree, but that is incompatible with notifiers that modify the node. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Nathan Fontenot <nfont@austin.ibm.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> (cherry picked from commit a25095d451ece23b1fef34474f3230100db7aa05) Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/of/dynamic.c')
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 3f2eb9fa7fb3..2f50de87ae08 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -98,6 +98,19 @@ int of_property_notify(int action, struct device_node *np,
void __of_attach_node(struct device_node *np)
+ const __be32 *phandle;
+ int sz;
+ np->name = __of_get_property(np, "name", NULL) ? : "<NULL>";
+ np->type = __of_get_property(np, "device_type", NULL) ? : "<NULL>";
+ phandle = __of_get_property(np, "phandle", &sz);
+ if (!phandle)
+ phandle = __of_get_property(np, "linux,phandle", &sz);
+ if (IS_ENABLED(PPC_PSERIES) && !phandle)
+ phandle = __of_get_property(np, "ibm,phandle", &sz);
+ np->phandle = (phandle && (sz >= 4)) ? be32_to_cpup(phandle) : 0;
np->child = NULL;
np->sibling = np->parent->child;
np->allnext = np->parent->allnext;