aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/prom_64.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-04 23:28:22 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-05 20:00:13 -0500
commitdfa76060be85dd48d3803bc26f6a6d2e93e812f0 (patch)
tree6e0256581241b0db0da33ce5afbd4017a61e38d8 /arch/sparc/kernel/prom_64.c
parentab04323e5b8c50d6e8f7f4a3e4118ba5fcba61a1 (diff)
sparc: Create common area for OF device layer code.
This is where common code implementations will go as we unify 32-bit and 64-bit OF device tree code. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/prom_64.c')
-rw-r--r--arch/sparc/kernel/prom_64.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index 651448d3cc5a..1f5666a94884 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -32,100 +32,6 @@
32 32
33#include "prom.h" 33#include "prom.h"
34 34
35struct device_node *of_find_node_by_phandle(phandle handle)
36{
37 struct device_node *np;
38
39 for (np = allnodes; np; np = np->allnext)
40 if (np->node == handle)
41 break;
42
43 return np;
44}
45EXPORT_SYMBOL(of_find_node_by_phandle);
46
47int of_getintprop_default(struct device_node *np, const char *name, int def)
48{
49 struct property *prop;
50 int len;
51
52 prop = of_find_property(np, name, &len);
53 if (!prop || len != 4)
54 return def;
55
56 return *(int *) prop->value;
57}
58EXPORT_SYMBOL(of_getintprop_default);
59
60DEFINE_MUTEX(of_set_property_mutex);
61EXPORT_SYMBOL(of_set_property_mutex);
62
63int of_set_property(struct device_node *dp, const char *name, void *val, int len)
64{
65 struct property **prevp;
66 void *new_val;
67 int err;
68
69 new_val = kmalloc(len, GFP_KERNEL);
70 if (!new_val)
71 return -ENOMEM;
72
73 memcpy(new_val, val, len);
74
75 err = -ENODEV;
76
77 write_lock(&devtree_lock);
78 prevp = &dp->properties;
79 while (*prevp) {
80 struct property *prop = *prevp;
81
82 if (!strcasecmp(prop->name, name)) {
83 void *old_val = prop->value;
84 int ret;
85
86 mutex_lock(&of_set_property_mutex);
87 ret = prom_setprop(dp->node, name, val, len);
88 mutex_unlock(&of_set_property_mutex);
89
90 err = -EINVAL;
91 if (ret >= 0) {
92 prop->value = new_val;
93 prop->length = len;
94
95 if (OF_IS_DYNAMIC(prop))
96 kfree(old_val);
97
98 OF_MARK_DYNAMIC(prop);
99
100 err = 0;
101 }
102 break;
103 }
104 prevp = &(*prevp)->next;
105 }
106 write_unlock(&devtree_lock);
107
108 /* XXX Upate procfs if necessary... */
109
110 return err;
111}
112EXPORT_SYMBOL(of_set_property);
113
114int of_find_in_proplist(const char *list, const char *match, int len)
115{
116 while (len > 0) {
117 int l;
118
119 if (!strcmp(list, match))
120 return 1;
121 l = strlen(list) + 1;
122 list += l;
123 len -= l;
124 }
125 return 0;
126}
127EXPORT_SYMBOL(of_find_in_proplist);
128
129static unsigned int prom_early_allocated __initdata; 35static unsigned int prom_early_allocated __initdata;
130 36
131static void * __init prom_early_alloc(unsigned long size) 37static void * __init prom_early_alloc(unsigned long size)