[SPARC]: Add unique device_node IDs and a ".node" property.

Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index c62fd3e..8e87e7e 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -584,7 +584,9 @@
 	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 @@
 		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 @@
 {
 	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 @@
 		return NULL;
 
 	dp = prom_early_alloc(sizeof(*dp));
+	dp->unique_id = unique_id++;
 
 	kref_init(&dp->kref);