diff options
author | David S. Miller <davem@davemloft.net> | 2008-12-05 04:10:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-05 20:09:10 -0500 |
commit | 7d9439d50b6dadcfdf6d28be2234461709719e14 (patch) | |
tree | add153d782e475df716e4c2371c3f23d019bcebe /arch/sparc/kernel/prom_common.c | |
parent | 06c0db7221de09cdf1d5dd2ce2780cc3361ad9f9 (diff) |
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.c | 41 |
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, | |||
184 | return p; | 184 | return p; |
185 | } | 185 | } |
186 | 186 | ||
187 | struct property * __init build_prop_list(phandle node) | 187 | static struct property * __init build_prop_list(phandle node) |
188 | { | 188 | { |
189 | struct property *head, *tail; | 189 | struct property *head, *tail; |
190 | 190 | ||
@@ -201,3 +201,42 @@ struct property * __init build_prop_list(phandle node) | |||
201 | 201 | ||
202 | return head; | 202 | return head; |
203 | } | 203 | } |
204 | |||
205 | static char * __init get_one_property(phandle node, const char *name) | ||
206 | { | ||
207 | char *buf = "<NULL>"; | ||
208 | int len; | ||
209 | |||
210 | len = prom_getproplen(node, name); | ||
211 | if (len > 0) { | ||
212 | buf = prom_early_alloc(len); | ||
213 | len = prom_getproperty(node, name, buf, len); | ||
214 | } | ||
215 | |||
216 | return buf; | ||
217 | } | ||
218 | |||
219 | struct device_node * __init create_node(phandle node, | ||
220 | struct device_node *parent) | ||
221 | { | ||
222 | struct device_node *dp; | ||
223 | |||
224 | if (!node) | ||
225 | return NULL; | ||
226 | |||
227 | dp = prom_early_alloc(sizeof(*dp)); | ||
228 | dp->unique_id = prom_unique_id++; | ||
229 | dp->parent = parent; | ||
230 | |||
231 | kref_init(&dp->kref); | ||
232 | |||
233 | dp->name = get_one_property(node, "name"); | ||
234 | dp->type = get_one_property(node, "device_type"); | ||
235 | dp->node = node; | ||
236 | |||
237 | /* Build interrupts later... */ | ||
238 | |||
239 | dp->properties = build_prop_list(node); | ||
240 | |||
241 | return dp; | ||
242 | } | ||