diff options
author | David S. Miller <davem@davemloft.net> | 2006-06-26 02:18:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-06-26 02:18:57 -0400 |
commit | 87b385da1f5a5f4a12a28e00fe597bcde8d6fea3 (patch) | |
tree | 6090a5fa706d81ed1a12f6769cc0d8371ea16044 /arch/sparc/kernel/prom.c | |
parent | fb7cd9d9acfb52dc1b9fbd5079445e4732667bbc (diff) |
[SPARC]: Add unique device_node IDs and a ".node" property.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/prom.c')
-rw-r--r-- | arch/sparc/kernel/prom.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c index f3f53f2e0e1e..946ce6d15819 100644 --- a/arch/sparc/kernel/prom.c +++ b/arch/sparc/kernel/prom.c | |||
@@ -407,7 +407,9 @@ static char * __init build_full_name(struct device_node *dp) | |||
407 | return n; | 407 | return n; |
408 | } | 408 | } |
409 | 409 | ||
410 | static struct property * __init build_one_prop(phandle node, char *prev) | 410 | static unsigned int unique_id; |
411 | |||
412 | static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len) | ||
411 | { | 413 | { |
412 | static struct property *tmp = NULL; | 414 | static struct property *tmp = NULL; |
413 | struct property *p; | 415 | struct property *p; |
@@ -417,25 +419,34 @@ static struct property * __init build_one_prop(phandle node, char *prev) | |||
417 | p = tmp; | 419 | p = tmp; |
418 | memset(p, 0, sizeof(*p) + 32); | 420 | memset(p, 0, sizeof(*p) + 32); |
419 | tmp = NULL; | 421 | tmp = NULL; |
420 | } else | 422 | } else { |
421 | p = prom_early_alloc(sizeof(struct property) + 32); | 423 | p = prom_early_alloc(sizeof(struct property) + 32); |
424 | p->unique_id = unique_id++; | ||
425 | } | ||
422 | 426 | ||
423 | p->name = (char *) (p + 1); | 427 | p->name = (char *) (p + 1); |
424 | if (prev == NULL) { | 428 | if (special_name) { |
425 | prom_firstprop(node, p->name); | 429 | p->length = special_len; |
430 | p->value = prom_early_alloc(special_len); | ||
431 | memcpy(p->value, special_val, special_len); | ||
426 | } else { | 432 | } else { |
427 | prom_nextprop(node, prev, p->name); | 433 | if (prev == NULL) { |
428 | } | 434 | prom_firstprop(node, p->name); |
429 | if (strlen(p->name) == 0) { | 435 | } else { |
430 | tmp = p; | 436 | prom_nextprop(node, prev, p->name); |
431 | return NULL; | 437 | } |
432 | } | 438 | if (strlen(p->name) == 0) { |
433 | p->length = prom_getproplen(node, p->name); | 439 | tmp = p; |
434 | if (p->length <= 0) { | 440 | return NULL; |
435 | p->length = 0; | 441 | } |
436 | } else { | 442 | p->length = prom_getproplen(node, p->name); |
437 | p->value = prom_early_alloc(p->length); | 443 | if (p->length <= 0) { |
438 | len = prom_getproperty(node, p->name, p->value, p->length); | 444 | p->length = 0; |
445 | } else { | ||
446 | p->value = prom_early_alloc(p->length + 1); | ||
447 | prom_getproperty(node, p->name, p->value, p->length); | ||
448 | ((unsigned char *)p->value)[p->length] = '\0'; | ||
449 | } | ||
439 | } | 450 | } |
440 | return p; | 451 | return p; |
441 | } | 452 | } |
@@ -444,9 +455,14 @@ static struct property * __init build_prop_list(phandle node) | |||
444 | { | 455 | { |
445 | struct property *head, *tail; | 456 | struct property *head, *tail; |
446 | 457 | ||
447 | head = tail = build_one_prop(node, NULL); | 458 | head = tail = build_one_prop(node, NULL, |
459 | ".node", &node, sizeof(node)); | ||
460 | |||
461 | tail->next = build_one_prop(node, NULL, NULL, NULL, 0); | ||
462 | tail = tail->next; | ||
448 | while(tail) { | 463 | while(tail) { |
449 | tail->next = build_one_prop(node, tail->name); | 464 | tail->next = build_one_prop(node, tail->name, |
465 | NULL, NULL, 0); | ||
450 | tail = tail->next; | 466 | tail = tail->next; |
451 | } | 467 | } |
452 | 468 | ||
@@ -475,6 +491,7 @@ static struct device_node * __init create_node(phandle node) | |||
475 | return NULL; | 491 | return NULL; |
476 | 492 | ||
477 | dp = prom_early_alloc(sizeof(*dp)); | 493 | dp = prom_early_alloc(sizeof(*dp)); |
494 | dp->unique_id = unique_id++; | ||
478 | 495 | ||
479 | kref_init(&dp->kref); | 496 | kref_init(&dp->kref); |
480 | 497 | ||