summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c4
-rw-r--r--drivers/of/dynamic.c13
-rw-r--r--drivers/of/of_private.h2
3 files changed, 17 insertions, 2 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ad4929cbd876..ededf8e33145 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -266,8 +266,8 @@ EXPORT_SYMBOL(of_find_all_nodes);
* Find a property with a given name for a given node
* and return the value.
*/
-static const void *__of_get_property(const struct device_node *np,
- const char *name, int *lenp)
+const void *__of_get_property(const struct device_node *np,
+ const char *name, int *lenp)
{
struct property *pp = __of_find_property(np, name, lenp);
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index b96d83100987..7c020b9a3317 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;
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 0d99ba8caeed..8129c0e58d70 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -63,6 +63,8 @@ static inline int of_property_notify(int action, struct device_node *np,
struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags);
struct device_node *__of_node_alloc(const char *full_name, gfp_t allocflags);
+extern const void *__of_get_property(const struct device_node *np,
+ const char *name, int *lenp);
extern int __of_add_property(struct device_node *np, struct property *prop);
extern int __of_add_property_sysfs(struct device_node *np,
struct property *prop);