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 | |
parent | fb7cd9d9acfb52dc1b9fbd5079445e4732667bbc (diff) |
[SPARC]: Add unique device_node IDs and a ".node" property.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/sparc/kernel/prom.c | 53 | ||||
-rw-r--r-- | arch/sparc64/kernel/prom.c | 54 | ||||
-rw-r--r-- | include/asm-sparc/prom.h | 2 | ||||
-rw-r--r-- | include/asm-sparc64/prom.h | 2 |
4 files changed, 75 insertions, 36 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 | ||
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 | ||
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h index e9b8047470fe..f9cf44c07164 100644 --- a/include/asm-sparc/prom.h +++ b/include/asm-sparc/prom.h | |||
@@ -36,6 +36,7 @@ struct property { | |||
36 | void *value; | 36 | void *value; |
37 | struct property *next; | 37 | struct property *next; |
38 | unsigned long _flags; | 38 | unsigned long _flags; |
39 | unsigned int unique_id; | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | struct device_node { | 42 | struct device_node { |
@@ -59,6 +60,7 @@ struct device_node { | |||
59 | struct kref kref; | 60 | struct kref kref; |
60 | unsigned long _flags; | 61 | unsigned long _flags; |
61 | void *data; | 62 | void *data; |
63 | unsigned int unique_id; | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | /* flag descriptions */ | 66 | /* flag descriptions */ |
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h index c8022a337380..265614d497c4 100644 --- a/include/asm-sparc64/prom.h +++ b/include/asm-sparc64/prom.h | |||
@@ -36,6 +36,7 @@ struct property { | |||
36 | void *value; | 36 | void *value; |
37 | struct property *next; | 37 | struct property *next; |
38 | unsigned long _flags; | 38 | unsigned long _flags; |
39 | unsigned int unique_id; | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | struct device_node { | 42 | struct device_node { |
@@ -59,6 +60,7 @@ struct device_node { | |||
59 | struct kref kref; | 60 | struct kref kref; |
60 | unsigned long _flags; | 61 | unsigned long _flags; |
61 | void *data; | 62 | void *data; |
63 | unsigned int unique_id; | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | /* flag descriptions */ | 66 | /* flag descriptions */ |