aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2010-10-10 23:52:57 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-10-12 23:58:08 -0400
commite2f2a93b6384cfe0face0be595bfbda1475d864b (patch)
treef379fda9976cba42f3fccb0bcbac71312db869d3 /drivers/of
parented41850298f7a55519de0b8573e217ed8a45c199 (diff)
of/promtree: add package-to-path support to pdt
package-to-path is a PROM function which tells us the real (full) name of the node. This provides a hook for that in the prom ops struct, and makes use of it in the pdt code when attempting to determine a node's name. If the hook is available, try using it (falling back to looking at the "name" property if it fails). Signed-off-by: Andres Salomon <dilinger@queued.net> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/pdt.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
index 31a4fb8694db..28295d0a50f6 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -132,6 +132,47 @@ static char * __init of_pdt_get_one_property(phandle node, const char *name)
132 return buf; 132 return buf;
133} 133}
134 134
135static char * __init of_pdt_try_pkg2path(phandle node)
136{
137 char *res, *buf = NULL;
138 int len;
139
140 if (!of_pdt_prom_ops->pkg2path)
141 return NULL;
142
143 if (of_pdt_prom_ops->pkg2path(node, buf, 0, &len))
144 return NULL;
145 buf = prom_early_alloc(len + 1);
146 if (of_pdt_prom_ops->pkg2path(node, buf, len, &len)) {
147 pr_err("%s: package-to-path failed\n", __func__);
148 return NULL;
149 }
150
151 res = strrchr(buf, '/');
152 if (!res) {
153 pr_err("%s: couldn't find / in %s\n", __func__, buf);
154 return NULL;
155 }
156 return res+1;
157}
158
159/*
160 * When fetching the node's name, first try using package-to-path; if
161 * that fails (either because the arch hasn't supplied a PROM callback,
162 * or some other random failure), fall back to just looking at the node's
163 * 'name' property.
164 */
165static char * __init of_pdt_build_name(phandle node)
166{
167 char *buf;
168
169 buf = of_pdt_try_pkg2path(node);
170 if (!buf)
171 buf = of_pdt_get_one_property(node, "name");
172
173 return buf;
174}
175
135static struct device_node * __init of_pdt_create_node(phandle node, 176static struct device_node * __init of_pdt_create_node(phandle node,
136 struct device_node *parent) 177 struct device_node *parent)
137{ 178{
@@ -146,7 +187,7 @@ static struct device_node * __init of_pdt_create_node(phandle node,
146 187
147 kref_init(&dp->kref); 188 kref_init(&dp->kref);
148 189
149 dp->name = of_pdt_get_one_property(node, "name"); 190 dp->name = of_pdt_build_name(node);
150 dp->type = of_pdt_get_one_property(node, "device_type"); 191 dp->type = of_pdt_get_one_property(node, "device_type");
151 dp->phandle = node; 192 dp->phandle = node;
152 193