summaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/prom_common.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-05 10:10:18 +0100
committerDavid S. Miller <davem@davemloft.net>2008-12-06 02:09:10 +0100
commit7d9439d50b6dadcfdf6d28be2234461709719e14 (patch)
treeadd153d782e475df716e4c2371c3f23d019bcebe /arch/sparc/kernel/prom_common.c
parentsparc: Make sparc32's create_node() assign parent pointer. (diff)
downloadlinux-7d9439d50b6dadcfdf6d28be2234461709719e14.tar.xz
linux-7d9439d50b6dadcfdf6d28be2234461709719e14.zip
sparc: Move create_node() and friends into prom_common.c
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/prom_common.c')
-rw-r--r--arch/sparc/kernel/prom_common.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 762056762b72..d3eddc76763d 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -184,7 +184,7 @@ static struct property * __init build_one_prop(phandle node, char *prev,
return p;
}
-struct property * __init build_prop_list(phandle node)
+static struct property * __init build_prop_list(phandle node)
{
struct property *head, *tail;
@@ -201,3 +201,42 @@ struct property * __init build_prop_list(phandle node)
return head;
}
+
+static char * __init get_one_property(phandle node, const char *name)
+{
+ char *buf = "<NULL>";
+ int len;
+
+ len = prom_getproplen(node, name);
+ if (len > 0) {
+ buf = prom_early_alloc(len);
+ len = prom_getproperty(node, name, buf, len);
+ }
+
+ return buf;
+}
+
+struct device_node * __init create_node(phandle node,
+ struct device_node *parent)
+{
+ struct device_node *dp;
+
+ if (!node)
+ return NULL;
+
+ dp = prom_early_alloc(sizeof(*dp));
+ dp->unique_id = prom_unique_id++;
+ dp->parent = parent;
+
+ kref_init(&dp->kref);
+
+ dp->name = get_one_property(node, "name");
+ dp->type = get_one_property(node, "device_type");
+ dp->node = node;
+
+ /* Build interrupts later... */
+
+ dp->properties = build_prop_list(node);
+
+ return dp;
+}