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/sparc64/kernel | |
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/sparc64/kernel')
-rw-r--r-- | arch/sparc64/kernel/prom.c | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index c62fd3e7a0f8..8e87e7ea0325 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c | |||
@@ -584,7 +584,9 @@ static char * __init build_full_name(struct device_node *dp) | |||
584 | return n; | 584 | return n; |
585 | } | 585 | } |
586 | 586 | ||
587 | static struct property * __init build_one_prop(phandle node, char *prev) | 587 | static unsigned int unique_id; |
588 | |||
589 | static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len) | ||
588 | { | 590 | { |
589 | static struct property *tmp = NULL; | 591 | static struct property *tmp = NULL; |
590 | struct property *p; | 592 | struct property *p; |
@@ -593,25 +595,35 @@ static struct property * __init build_one_prop(phandle node, char *prev) | |||
593 | p = tmp; | 595 | p = tmp; |
594 | memset(p, 0, sizeof(*p) + 32); | 596 | memset(p, 0, sizeof(*p) + 32); |
595 | tmp = NULL; | 597 | tmp = NULL; |
596 | } else | 598 | } else { |
597 | p = prom_early_alloc(sizeof(struct property) + 32); | 599 | p = prom_early_alloc(sizeof(struct property) + 32); |
600 | p->unique_id = unique_id++; | ||
601 | } | ||
598 | 602 | ||
599 | p->name = (char *) (p + 1); | 603 | p->name = (char *) (p + 1); |
600 | if (prev == NULL) { | 604 | if (special_name) { |
601 | prom_firstprop(node, p->name); | 605 | strcpy(p->name, special_name); |
606 | p->length = special_len; | ||
607 | p->value = prom_early_alloc(special_len); | ||
608 | memcpy(p->value, special_val, special_len); | ||
602 | } else { | 609 | } else { |
603 | prom_nextprop(node, prev, p->name); | 610 | if (prev == NULL) { |
604 | } | 611 | prom_firstprop(node, p->name); |
605 | if (strlen(p->name) == 0) { | 612 | } else { |
606 | tmp = p; | 613 | prom_nextprop(node, prev, p->name); |
607 | return NULL; | 614 | } |
608 | } | 615 | if (strlen(p->name) == 0) { |
609 | p->length = prom_getproplen(node, p->name); | 616 | tmp = p; |
610 | if (p->length <= 0) { | 617 | return NULL; |
611 | p->length = 0; | 618 | } |
612 | } else { | 619 | p->length = prom_getproplen(node, p->name); |
613 | p->value = prom_early_alloc(p->length); | 620 | if (p->length <= 0) { |
614 | prom_getproperty(node, p->name, p->value, p->length); | 621 | p->length = 0; |
622 | } else { | ||
623 | p->value = prom_early_alloc(p->length + 1); | ||
624 | prom_getproperty(node, p->name, p->value, p->length); | ||
625 | ((unsigned char *)p->value)[p->length] = '\0'; | ||
626 | } | ||
615 | } | 627 | } |
616 | return p; | 628 | return p; |
617 | } | 629 | } |
@@ -620,9 +632,14 @@ static struct property * __init build_prop_list(phandle node) | |||
620 | { | 632 | { |
621 | struct property *head, *tail; | 633 | struct property *head, *tail; |
622 | 634 | ||
623 | head = tail = build_one_prop(node, NULL); | 635 | head = tail = build_one_prop(node, NULL, |
636 | ".node", &node, sizeof(node)); | ||
637 | |||
638 | tail->next = build_one_prop(node, NULL, NULL, NULL, 0); | ||
639 | tail = tail->next; | ||
624 | while(tail) { | 640 | while(tail) { |
625 | tail->next = build_one_prop(node, tail->name); | 641 | tail->next = build_one_prop(node, tail->name, |
642 | NULL, NULL, 0); | ||
626 | tail = tail->next; | 643 | tail = tail->next; |
627 | } | 644 | } |
628 | 645 | ||
@@ -651,6 +668,7 @@ static struct device_node * __init create_node(phandle node) | |||
651 | return NULL; | 668 | return NULL; |
652 | 669 | ||
653 | dp = prom_early_alloc(sizeof(*dp)); | 670 | dp = prom_early_alloc(sizeof(*dp)); |
671 | dp->unique_id = unique_id++; | ||
654 | 672 | ||
655 | kref_init(&dp->kref); | 673 | kref_init(&dp->kref); |
656 | 674 | ||