hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/of/pdt.c
....@@ -21,8 +21,6 @@
2121
2222 static struct of_pdt_ops *of_pdt_prom_ops __initdata;
2323
24
-void __initdata (*of_pdt_build_more)(struct device_node *dp);
25
-
2624 #if defined(CONFIG_SPARC)
2725 unsigned int of_pdt_unique_id __initdata;
2826
....@@ -32,24 +30,7 @@
3230
3331 static char * __init of_pdt_build_full_name(struct device_node *dp)
3432 {
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);
5334 }
5435
5536 #else /* CONFIG_SPARC */
....@@ -60,23 +41,21 @@
6041 static char * __init of_pdt_build_full_name(struct device_node *dp)
6142 {
6243 static int failsafe_id = 0; /* for generating unique names on failure */
44
+ const char *name;
45
+ char path[256];
6346 char *buf;
6447 int len;
6548
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
+ }
6855
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++);
8059 pr_err("%s: pkg2path failed; assigning %s\n", __func__, buf);
8160 return buf;
8261 }
....@@ -176,10 +155,11 @@
176155 dp->parent = parent;
177156
178157 dp->name = of_pdt_get_one_property(node, "name");
179
- dp->type = of_pdt_get_one_property(node, "device_type");
180158 dp->phandle = node;
181159
182160 dp->properties = of_pdt_build_prop_list(node);
161
+
162
+ dp->full_name = of_pdt_build_full_name(dp);
183163
184164 irq_trans_init(dp);
185165
....@@ -204,12 +184,7 @@
204184 ret = dp;
205185 prev_sibling = dp;
206186
207
- dp->full_name = of_pdt_build_full_name(dp);
208
-
209187 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);
213188
214189 node = of_pdt_prom_ops->getsibling(node);
215190 }
....@@ -228,9 +203,6 @@
228203 of_pdt_prom_ops = ops;
229204
230205 of_root = of_pdt_create_node(root_node, NULL);
231
-#if defined(CONFIG_SPARC)
232
- of_root->path_component_name = "";
233
-#endif
234206 of_root->full_name = "/";
235207
236208 of_root->child = of_pdt_build_tree(of_root,