]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[SPARC]: Add unique device_node IDs and a ".node" property.
authorDavid S. Miller <davem@davemloft.net>
Mon, 26 Jun 2006 06:18:57 +0000 (23:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 26 Jun 2006 06:18:57 +0000 (23:18 -0700)
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/prom.c
arch/sparc64/kernel/prom.c
include/asm-sparc/prom.h
include/asm-sparc64/prom.h

index f3f53f2e0e1e03e70fc797c4300c078f4e952842..946ce6d15819ae12448e2d4bc2bf86df0d2f7dc3 100644 (file)
@@ -407,7 +407,9 @@ static char * __init build_full_name(struct device_node *dp)
        return n;
 }
 
-static struct property * __init build_one_prop(phandle node, char *prev)
+static unsigned int unique_id;
+
+static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
 {
        static struct property *tmp = NULL;
        struct property *p;
@@ -417,25 +419,34 @@ static struct property * __init build_one_prop(phandle node, char *prev)
                p = tmp;
                memset(p, 0, sizeof(*p) + 32);
                tmp = NULL;
-       } else
+       } else {
                p = prom_early_alloc(sizeof(struct property) + 32);
+               p->unique_id = unique_id++;
+       }
 
        p->name = (char *) (p + 1);
-       if (prev == NULL) {
-               prom_firstprop(node, p->name);
+       if (special_name) {
+               p->length = special_len;
+               p->value = prom_early_alloc(special_len);
+               memcpy(p->value, special_val, special_len);
        } else {
-               prom_nextprop(node, prev, p->name);
-       }
-       if (strlen(p->name) == 0) {
-               tmp = p;
-               return NULL;
-       }
-       p->length = prom_getproplen(node, p->name);
-       if (p->length <= 0) {
-               p->length = 0;
-       } else {
-               p->value = prom_early_alloc(p->length);
-               len = prom_getproperty(node, p->name, p->value, p->length);
+               if (prev == NULL) {
+                       prom_firstprop(node, p->name);
+               } else {
+                       prom_nextprop(node, prev, p->name);
+               }
+               if (strlen(p->name) == 0) {
+                       tmp = p;
+                       return NULL;
+               }
+               p->length = prom_getproplen(node, p->name);
+               if (p->length <= 0) {
+                       p->length = 0;
+               } else {
+                       p->value = prom_early_alloc(p->length + 1);
+                       prom_getproperty(node, p->name, p->value, p->length);
+                       ((unsigned char *)p->value)[p->length] = '\0';
+               }
        }
        return p;
 }
@@ -444,9 +455,14 @@ static struct property * __init build_prop_list(phandle node)
 {
        struct property *head, *tail;
 
-       head = tail = build_one_prop(node, NULL);
+       head = tail = build_one_prop(node, NULL,
+                                    ".node", &node, sizeof(node));
+
+       tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
+       tail = tail->next;
        while(tail) {
-               tail->next = build_one_prop(node, tail->name);
+               tail->next = build_one_prop(node, tail->name,
+                                           NULL, NULL, 0);
                tail = tail->next;
        }
 
@@ -475,6 +491,7 @@ static struct device_node * __init create_node(phandle node)
                return NULL;
 
        dp = prom_early_alloc(sizeof(*dp));
+       dp->unique_id = unique_id++;
 
        kref_init(&dp->kref);
 
index c62fd3e7a0f81e265149ee3a12a2aab0d48c9ef2..8e87e7ea0325bb5861ddbf3f16c523416c70ac9c 100644 (file)
@@ -584,7 +584,9 @@ static char * __init build_full_name(struct device_node *dp)
        return n;
 }
 
-static struct property * __init build_one_prop(phandle node, char *prev)
+static unsigned int unique_id;
+
+static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
 {
        static struct property *tmp = NULL;
        struct property *p;
@@ -593,25 +595,35 @@ static struct property * __init build_one_prop(phandle node, char *prev)
                p = tmp;
                memset(p, 0, sizeof(*p) + 32);
                tmp = NULL;
-       } else
+       } else {
                p = prom_early_alloc(sizeof(struct property) + 32);
+               p->unique_id = unique_id++;
+       }
 
        p->name = (char *) (p + 1);
-       if (prev == NULL) {
-               prom_firstprop(node, p->name);
+       if (special_name) {
+               strcpy(p->name, special_name);
+               p->length = special_len;
+               p->value = prom_early_alloc(special_len);
+               memcpy(p->value, special_val, special_len);
        } else {
-               prom_nextprop(node, prev, p->name);
-       }
-       if (strlen(p->name) == 0) {
-               tmp = p;
-               return NULL;
-       }
-       p->length = prom_getproplen(node, p->name);
-       if (p->length <= 0) {
-               p->length = 0;
-       } else {
-               p->value = prom_early_alloc(p->length);
-               prom_getproperty(node, p->name, p->value, p->length);
+               if (prev == NULL) {
+                       prom_firstprop(node, p->name);
+               } else {
+                       prom_nextprop(node, prev, p->name);
+               }
+               if (strlen(p->name) == 0) {
+                       tmp = p;
+                       return NULL;
+               }
+               p->length = prom_getproplen(node, p->name);
+               if (p->length <= 0) {
+                       p->length = 0;
+               } else {
+                       p->value = prom_early_alloc(p->length + 1);
+                       prom_getproperty(node, p->name, p->value, p->length);
+                       ((unsigned char *)p->value)[p->length] = '\0';
+               }
        }
        return p;
 }
@@ -620,9 +632,14 @@ static struct property * __init build_prop_list(phandle node)
 {
        struct property *head, *tail;
 
-       head = tail = build_one_prop(node, NULL);
+       head = tail = build_one_prop(node, NULL,
+                                    ".node", &node, sizeof(node));
+
+       tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
+       tail = tail->next;
        while(tail) {
-               tail->next = build_one_prop(node, tail->name);
+               tail->next = build_one_prop(node, tail->name,
+                                           NULL, NULL, 0);
                tail = tail->next;
        }
 
@@ -651,6 +668,7 @@ static struct device_node * __init create_node(phandle node)
                return NULL;
 
        dp = prom_early_alloc(sizeof(*dp));
+       dp->unique_id = unique_id++;
 
        kref_init(&dp->kref);
 
index e9b8047470fe02efe564067fb86b4620b4c86f7f..f9cf44c0716428d56971062ab29db6a35164a290 100644 (file)
@@ -36,6 +36,7 @@ struct property {
        void    *value;
        struct property *next;
        unsigned long _flags;
+       unsigned int unique_id;
 };
 
 struct device_node {
@@ -59,6 +60,7 @@ struct device_node {
        struct  kref kref;
        unsigned long _flags;
        void    *data;
+       unsigned int unique_id;
 };
 
 /* flag descriptions */
index c8022a337380721461a9371de5514ee4d3558565..265614d497c43990bc0087cee48d7c401986af79 100644 (file)
@@ -36,6 +36,7 @@ struct property {
        void    *value;
        struct property *next;
        unsigned long _flags;
+       unsigned int unique_id;
 };
 
 struct device_node {
@@ -59,6 +60,7 @@ struct device_node {
        struct  kref kref;
        unsigned long _flags;
        void    *data;
+       unsigned int unique_id;
 };
 
 /* flag descriptions */