.. | .. |
---|
21 | 21 | |
---|
22 | 22 | static struct of_pdt_ops *of_pdt_prom_ops __initdata; |
---|
23 | 23 | |
---|
24 | | -void __initdata (*of_pdt_build_more)(struct device_node *dp); |
---|
25 | | - |
---|
26 | 24 | #if defined(CONFIG_SPARC) |
---|
27 | 25 | unsigned int of_pdt_unique_id __initdata; |
---|
28 | 26 | |
---|
.. | .. |
---|
32 | 30 | |
---|
33 | 31 | static char * __init of_pdt_build_full_name(struct device_node *dp) |
---|
34 | 32 | { |
---|
35 | | - int len, ourlen, plen; |
---|
36 | | - char *n; |
---|
37 | | - |
---|
38 | | - dp->path_component_name = build_path_component(dp); |
---|
39 | | - |
---|
40 | | - plen = strlen(dp->parent->full_name); |
---|
41 | | - ourlen = strlen(dp->path_component_name); |
---|
42 | | - len = ourlen + plen + 2; |
---|
43 | | - |
---|
44 | | - n = prom_early_alloc(len); |
---|
45 | | - strcpy(n, dp->parent->full_name); |
---|
46 | | - if (!of_node_is_root(dp->parent)) { |
---|
47 | | - strcpy(n + plen, "/"); |
---|
48 | | - plen++; |
---|
49 | | - } |
---|
50 | | - strcpy(n + plen, dp->path_component_name); |
---|
51 | | - |
---|
52 | | - return n; |
---|
| 33 | + return build_path_component(dp); |
---|
53 | 34 | } |
---|
54 | 35 | |
---|
55 | 36 | #else /* CONFIG_SPARC */ |
---|
.. | .. |
---|
60 | 41 | static char * __init of_pdt_build_full_name(struct device_node *dp) |
---|
61 | 42 | { |
---|
62 | 43 | static int failsafe_id = 0; /* for generating unique names on failure */ |
---|
| 44 | + const char *name; |
---|
| 45 | + char path[256]; |
---|
63 | 46 | char *buf; |
---|
64 | 47 | int len; |
---|
65 | 48 | |
---|
66 | | - if (of_pdt_prom_ops->pkg2path(dp->phandle, NULL, 0, &len)) |
---|
67 | | - goto failsafe; |
---|
| 49 | + if (!of_pdt_prom_ops->pkg2path(dp->phandle, path, sizeof(path), &len)) { |
---|
| 50 | + name = kbasename(path); |
---|
| 51 | + buf = prom_early_alloc(strlen(name) + 1); |
---|
| 52 | + strcpy(buf, name); |
---|
| 53 | + return buf; |
---|
| 54 | + } |
---|
68 | 55 | |
---|
69 | | - buf = prom_early_alloc(len + 1); |
---|
70 | | - if (of_pdt_prom_ops->pkg2path(dp->phandle, buf, len, &len)) |
---|
71 | | - goto failsafe; |
---|
72 | | - return buf; |
---|
73 | | - |
---|
74 | | - failsafe: |
---|
75 | | - buf = prom_early_alloc(strlen(dp->parent->full_name) + |
---|
76 | | - strlen(dp->name) + 16); |
---|
77 | | - sprintf(buf, "%s/%s@unknown%i", |
---|
78 | | - of_node_is_root(dp->parent) ? "" : dp->parent->full_name, |
---|
79 | | - dp->name, failsafe_id++); |
---|
| 56 | + name = of_get_property(dp, "name", &len); |
---|
| 57 | + buf = prom_early_alloc(len + 16); |
---|
| 58 | + sprintf(buf, "%s@unknown%i", name, failsafe_id++); |
---|
80 | 59 | pr_err("%s: pkg2path failed; assigning %s\n", __func__, buf); |
---|
81 | 60 | return buf; |
---|
82 | 61 | } |
---|
.. | .. |
---|
176 | 155 | dp->parent = parent; |
---|
177 | 156 | |
---|
178 | 157 | dp->name = of_pdt_get_one_property(node, "name"); |
---|
179 | | - dp->type = of_pdt_get_one_property(node, "device_type"); |
---|
180 | 158 | dp->phandle = node; |
---|
181 | 159 | |
---|
182 | 160 | dp->properties = of_pdt_build_prop_list(node); |
---|
| 161 | + |
---|
| 162 | + dp->full_name = of_pdt_build_full_name(dp); |
---|
183 | 163 | |
---|
184 | 164 | irq_trans_init(dp); |
---|
185 | 165 | |
---|
.. | .. |
---|
204 | 184 | ret = dp; |
---|
205 | 185 | prev_sibling = dp; |
---|
206 | 186 | |
---|
207 | | - dp->full_name = of_pdt_build_full_name(dp); |
---|
208 | | - |
---|
209 | 187 | dp->child = of_pdt_build_tree(dp, of_pdt_prom_ops->getchild(node)); |
---|
210 | | - |
---|
211 | | - if (of_pdt_build_more) |
---|
212 | | - of_pdt_build_more(dp); |
---|
213 | 188 | |
---|
214 | 189 | node = of_pdt_prom_ops->getsibling(node); |
---|
215 | 190 | } |
---|
.. | .. |
---|
228 | 203 | of_pdt_prom_ops = ops; |
---|
229 | 204 | |
---|
230 | 205 | of_root = of_pdt_create_node(root_node, NULL); |
---|
231 | | -#if defined(CONFIG_SPARC) |
---|
232 | | - of_root->path_component_name = ""; |
---|
233 | | -#endif |
---|
234 | 206 | of_root->full_name = "/"; |
---|
235 | 207 | |
---|
236 | 208 | of_root->child = of_pdt_build_tree(of_root, |
---|