diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-07-18 18:15:45 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-20 00:27:18 -0400 |
commit | 91ba3c2128e9ee490a9f04bcd5b54749b18e4410 (patch) | |
tree | c90f5711b990468dc684a8859cc9c498b8d4163d /arch/sparc64/kernel/mdesc.c | |
parent | 48db7b7c50cdb06c85f0ff01b5c19ac34903048b (diff) |
[SPARC64]: Fix handling of multiple vdc-port nodes.
The "id" property in vdc-port nodes are not unique, they
are all zero. Therefore assign ID's using the parent's
"cfg-handle" property which will be unique.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/mdesc.c')
-rw-r--r-- | arch/sparc64/kernel/mdesc.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c index 302ba5e5a0bb..13a79fe5115b 100644 --- a/arch/sparc64/kernel/mdesc.c +++ b/arch/sparc64/kernel/mdesc.c | |||
@@ -231,6 +231,25 @@ void mdesc_register_notifier(struct mdesc_notifier_client *client) | |||
231 | mutex_unlock(&mdesc_mutex); | 231 | mutex_unlock(&mdesc_mutex); |
232 | } | 232 | } |
233 | 233 | ||
234 | static const u64 *parent_cfg_handle(struct mdesc_handle *hp, u64 node) | ||
235 | { | ||
236 | const u64 *id; | ||
237 | u64 a; | ||
238 | |||
239 | id = NULL; | ||
240 | mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) { | ||
241 | u64 target; | ||
242 | |||
243 | target = mdesc_arc_target(hp, a); | ||
244 | id = mdesc_get_property(hp, target, | ||
245 | "cfg-handle", NULL); | ||
246 | if (id) | ||
247 | break; | ||
248 | } | ||
249 | |||
250 | return id; | ||
251 | } | ||
252 | |||
234 | /* Run 'func' on nodes which are in A but not in B. */ | 253 | /* Run 'func' on nodes which are in A but not in B. */ |
235 | static void invoke_on_missing(const char *name, | 254 | static void invoke_on_missing(const char *name, |
236 | struct mdesc_handle *a, | 255 | struct mdesc_handle *a, |
@@ -240,13 +259,42 @@ static void invoke_on_missing(const char *name, | |||
240 | u64 node; | 259 | u64 node; |
241 | 260 | ||
242 | mdesc_for_each_node_by_name(a, node, name) { | 261 | mdesc_for_each_node_by_name(a, node, name) { |
243 | const u64 *id = mdesc_get_property(a, node, "id", NULL); | 262 | int found = 0, is_vdc_port = 0; |
244 | int found = 0; | 263 | const char *name_prop; |
264 | const u64 *id; | ||
245 | u64 fnode; | 265 | u64 fnode; |
246 | 266 | ||
267 | name_prop = mdesc_get_property(a, node, "name", NULL); | ||
268 | if (name_prop && !strcmp(name_prop, "vdc-port")) { | ||
269 | is_vdc_port = 1; | ||
270 | id = parent_cfg_handle(a, node); | ||
271 | } else | ||
272 | id = mdesc_get_property(a, node, "id", NULL); | ||
273 | |||
274 | if (!id) { | ||
275 | printk(KERN_ERR "MD: Cannot find ID for %s node.\n", | ||
276 | (name_prop ? name_prop : name)); | ||
277 | continue; | ||
278 | } | ||
279 | |||
247 | mdesc_for_each_node_by_name(b, fnode, name) { | 280 | mdesc_for_each_node_by_name(b, fnode, name) { |
248 | const u64 *fid = mdesc_get_property(b, fnode, | 281 | const u64 *fid; |
249 | "id", NULL); | 282 | |
283 | if (is_vdc_port) { | ||
284 | name_prop = mdesc_get_property(b, fnode, | ||
285 | "name", NULL); | ||
286 | if (!name_prop || | ||
287 | strcmp(name_prop, "vdc-port")) | ||
288 | continue; | ||
289 | fid = parent_cfg_handle(b, fnode); | ||
290 | if (!fid) { | ||
291 | printk(KERN_ERR "MD: Cannot find ID " | ||
292 | "for vdc-port node.\n"); | ||
293 | continue; | ||
294 | } | ||
295 | } else | ||
296 | fid = mdesc_get_property(b, fnode, | ||
297 | "id", NULL); | ||
250 | 298 | ||
251 | if (*id == *fid) { | 299 | if (*id == *fid) { |
252 | found = 1; | 300 | found = 1; |