aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/prom_32.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_32.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_32.c')
-rw-r--r--arch/sparc/kernel/prom_32.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c
index 715455ba3689..e41df66192e5 100644
--- a/arch/sparc/kernel/prom_32.c
+++ b/arch/sparc/kernel/prom_32.c
@@ -27,100 +27,6 @@
27 27
28#include "prom.h" 28#include "prom.h"
29 29
30struct device_node *of_find_node_by_phandle(phandle handle)
31{
32 struct device_node *np;
33
34 for (np = allnodes; np != 0; np = np->allnext)
35 if (np->node == handle)
36 break;
37
38 return np;
39}
40EXPORT_SYMBOL(of_find_node_by_phandle);
41
42int of_getintprop_default(struct device_node *np, const char *name, int def)
43{
44 struct property *prop;
45 int len;
46
47 prop = of_find_property(np, name, &len);
48 if (!prop || len != 4)
49 return def;
50
51 return *(int *) prop->value;
52}
53EXPORT_SYMBOL(of_getintprop_default);
54
55DEFINE_MUTEX(of_set_property_mutex);
56EXPORT_SYMBOL(of_set_property_mutex);
57
58int of_set_property(struct device_node *dp, const char *name, void *val, int len)
59{
60 struct property **prevp;
61 void *new_val;
62 int err;
63
64 new_val = kmalloc(len, GFP_KERNEL);
65 if (!new_val)
66 return -ENOMEM;
67
68 memcpy(new_val, val, len);
69
70 err = -ENODEV;
71
72 write_lock(&devtree_lock);
73 prevp = &dp->properties;
74 while (*prevp) {
75 struct property *prop = *prevp;
76
77 if (!strcasecmp(prop->name, name)) {
78 void *old_val = prop->value;
79 int ret;
80
81 mutex_lock(&of_set_property_mutex);
82 ret = prom_setprop(dp->node, (char *) name, val, len);
83 mutex_unlock(&of_set_property_mutex);
84
85 err = -EINVAL;
86 if (ret >= 0) {
87 prop->value = new_val;
88 prop->length = len;
89
90 if (OF_IS_DYNAMIC(prop))
91 kfree(old_val);
92
93 OF_MARK_DYNAMIC(prop);
94
95 err = 0;
96 }
97 break;
98 }
99 prevp = &(*prevp)->next;
100 }
101 write_unlock(&devtree_lock);
102
103 /* XXX Upate procfs if necessary... */
104
105 return err;
106}
107EXPORT_SYMBOL(of_set_property);
108
109int of_find_in_proplist(const char *list, const char *match, int len)
110{
111 while (len > 0) {
112 int l;
113
114 if (!strcmp(list, match))
115 return 1;
116 l = strlen(list) + 1;
117 list += l;
118 len -= l;
119 }
120 return 0;
121}
122EXPORT_SYMBOL(of_find_in_proplist);
123
124static unsigned int prom_early_allocated; 30static unsigned int prom_early_allocated;
125 31
126static void * __init prom_early_alloc(unsigned long size) 32static void * __init prom_early_alloc(unsigned long size)