diff options
author | Stephen Neuendorffer <stephen.neuendorffer@xilinx.com> | 2010-11-18 18:55:01 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-12-29 19:00:26 -0500 |
commit | 57d00ecf90cc9854973da2960012b734acc26e51 (patch) | |
tree | 6f1f3ce92b5e21646f4ec75766e3a2f5cba11fde /drivers/of | |
parent | a40d6c4cf12d87980c10b230df435d0f56adc40b (diff) |
of/flattree: Reorder unflatten_dt_node
Move unflatten_dt_node to be grouped with non-__init functions.
Signed-off-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/fdt.c | 218 |
1 files changed, 109 insertions, 109 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index cf74e546faf2..71edc9cecd62 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -97,115 +97,6 @@ int of_fdt_is_compatible(struct boot_param_header *blob, | |||
97 | return 0; | 97 | return 0; |
98 | } | 98 | } |
99 | 99 | ||
100 | /* Everything below here references initial_boot_params directly. */ | ||
101 | int __initdata dt_root_addr_cells; | ||
102 | int __initdata dt_root_size_cells; | ||
103 | |||
104 | struct boot_param_header *initial_boot_params; | ||
105 | |||
106 | #ifdef CONFIG_OF_EARLY_FLATTREE | ||
107 | |||
108 | /** | ||
109 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. | ||
110 | * @it: callback function | ||
111 | * @data: context data pointer | ||
112 | * | ||
113 | * This function is used to scan the flattened device-tree, it is | ||
114 | * used to extract the memory information at boot before we can | ||
115 | * unflatten the tree | ||
116 | */ | ||
117 | int __init of_scan_flat_dt(int (*it)(unsigned long node, | ||
118 | const char *uname, int depth, | ||
119 | void *data), | ||
120 | void *data) | ||
121 | { | ||
122 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
123 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
124 | int rc = 0; | ||
125 | int depth = -1; | ||
126 | |||
127 | do { | ||
128 | u32 tag = be32_to_cpup((__be32 *)p); | ||
129 | char *pathp; | ||
130 | |||
131 | p += 4; | ||
132 | if (tag == OF_DT_END_NODE) { | ||
133 | depth--; | ||
134 | continue; | ||
135 | } | ||
136 | if (tag == OF_DT_NOP) | ||
137 | continue; | ||
138 | if (tag == OF_DT_END) | ||
139 | break; | ||
140 | if (tag == OF_DT_PROP) { | ||
141 | u32 sz = be32_to_cpup((__be32 *)p); | ||
142 | p += 8; | ||
143 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | ||
144 | p = ALIGN(p, sz >= 8 ? 8 : 4); | ||
145 | p += sz; | ||
146 | p = ALIGN(p, 4); | ||
147 | continue; | ||
148 | } | ||
149 | if (tag != OF_DT_BEGIN_NODE) { | ||
150 | pr_err("Invalid tag %x in flat device tree!\n", tag); | ||
151 | return -EINVAL; | ||
152 | } | ||
153 | depth++; | ||
154 | pathp = (char *)p; | ||
155 | p = ALIGN(p + strlen(pathp) + 1, 4); | ||
156 | if ((*pathp) == '/') { | ||
157 | char *lp, *np; | ||
158 | for (lp = NULL, np = pathp; *np; np++) | ||
159 | if ((*np) == '/') | ||
160 | lp = np+1; | ||
161 | if (lp != NULL) | ||
162 | pathp = lp; | ||
163 | } | ||
164 | rc = it(p, pathp, depth, data); | ||
165 | if (rc != 0) | ||
166 | break; | ||
167 | } while (1); | ||
168 | |||
169 | return rc; | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * of_get_flat_dt_root - find the root node in the flat blob | ||
174 | */ | ||
175 | unsigned long __init of_get_flat_dt_root(void) | ||
176 | { | ||
177 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
178 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
179 | |||
180 | while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) | ||
181 | p += 4; | ||
182 | BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); | ||
183 | p += 4; | ||
184 | return ALIGN(p + strlen((char *)p) + 1, 4); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr | ||
189 | * | ||
190 | * This function can be used within scan_flattened_dt callback to get | ||
191 | * access to properties | ||
192 | */ | ||
193 | void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | ||
194 | unsigned long *size) | ||
195 | { | ||
196 | return of_fdt_get_property(initial_boot_params, node, name, size); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * of_flat_dt_is_compatible - Return true if given node has compat in compatible list | ||
201 | * @node: node to test | ||
202 | * @compat: compatible string to compare with compatible list. | ||
203 | */ | ||
204 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
205 | { | ||
206 | return of_fdt_is_compatible(initial_boot_params, node, compat); | ||
207 | } | ||
208 | |||
209 | static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, | 100 | static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, |
210 | unsigned long align) | 101 | unsigned long align) |
211 | { | 102 | { |
@@ -421,6 +312,115 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob, | |||
421 | return mem; | 312 | return mem; |
422 | } | 313 | } |
423 | 314 | ||
315 | /* Everything below here references initial_boot_params directly. */ | ||
316 | int __initdata dt_root_addr_cells; | ||
317 | int __initdata dt_root_size_cells; | ||
318 | |||
319 | struct boot_param_header *initial_boot_params; | ||
320 | |||
321 | #ifdef CONFIG_OF_EARLY_FLATTREE | ||
322 | |||
323 | /** | ||
324 | * of_scan_flat_dt - scan flattened tree blob and call callback on each. | ||
325 | * @it: callback function | ||
326 | * @data: context data pointer | ||
327 | * | ||
328 | * This function is used to scan the flattened device-tree, it is | ||
329 | * used to extract the memory information at boot before we can | ||
330 | * unflatten the tree | ||
331 | */ | ||
332 | int __init of_scan_flat_dt(int (*it)(unsigned long node, | ||
333 | const char *uname, int depth, | ||
334 | void *data), | ||
335 | void *data) | ||
336 | { | ||
337 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
338 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
339 | int rc = 0; | ||
340 | int depth = -1; | ||
341 | |||
342 | do { | ||
343 | u32 tag = be32_to_cpup((__be32 *)p); | ||
344 | char *pathp; | ||
345 | |||
346 | p += 4; | ||
347 | if (tag == OF_DT_END_NODE) { | ||
348 | depth--; | ||
349 | continue; | ||
350 | } | ||
351 | if (tag == OF_DT_NOP) | ||
352 | continue; | ||
353 | if (tag == OF_DT_END) | ||
354 | break; | ||
355 | if (tag == OF_DT_PROP) { | ||
356 | u32 sz = be32_to_cpup((__be32 *)p); | ||
357 | p += 8; | ||
358 | if (be32_to_cpu(initial_boot_params->version) < 0x10) | ||
359 | p = ALIGN(p, sz >= 8 ? 8 : 4); | ||
360 | p += sz; | ||
361 | p = ALIGN(p, 4); | ||
362 | continue; | ||
363 | } | ||
364 | if (tag != OF_DT_BEGIN_NODE) { | ||
365 | pr_err("Invalid tag %x in flat device tree!\n", tag); | ||
366 | return -EINVAL; | ||
367 | } | ||
368 | depth++; | ||
369 | pathp = (char *)p; | ||
370 | p = ALIGN(p + strlen(pathp) + 1, 4); | ||
371 | if ((*pathp) == '/') { | ||
372 | char *lp, *np; | ||
373 | for (lp = NULL, np = pathp; *np; np++) | ||
374 | if ((*np) == '/') | ||
375 | lp = np+1; | ||
376 | if (lp != NULL) | ||
377 | pathp = lp; | ||
378 | } | ||
379 | rc = it(p, pathp, depth, data); | ||
380 | if (rc != 0) | ||
381 | break; | ||
382 | } while (1); | ||
383 | |||
384 | return rc; | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * of_get_flat_dt_root - find the root node in the flat blob | ||
389 | */ | ||
390 | unsigned long __init of_get_flat_dt_root(void) | ||
391 | { | ||
392 | unsigned long p = ((unsigned long)initial_boot_params) + | ||
393 | be32_to_cpu(initial_boot_params->off_dt_struct); | ||
394 | |||
395 | while (be32_to_cpup((__be32 *)p) == OF_DT_NOP) | ||
396 | p += 4; | ||
397 | BUG_ON(be32_to_cpup((__be32 *)p) != OF_DT_BEGIN_NODE); | ||
398 | p += 4; | ||
399 | return ALIGN(p + strlen((char *)p) + 1, 4); | ||
400 | } | ||
401 | |||
402 | /** | ||
403 | * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr | ||
404 | * | ||
405 | * This function can be used within scan_flattened_dt callback to get | ||
406 | * access to properties | ||
407 | */ | ||
408 | void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | ||
409 | unsigned long *size) | ||
410 | { | ||
411 | return of_fdt_get_property(initial_boot_params, node, name, size); | ||
412 | } | ||
413 | |||
414 | /** | ||
415 | * of_flat_dt_is_compatible - Return true if given node has compat in compatible list | ||
416 | * @node: node to test | ||
417 | * @compat: compatible string to compare with compatible list. | ||
418 | */ | ||
419 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
420 | { | ||
421 | return of_fdt_is_compatible(initial_boot_params, node, compat); | ||
422 | } | ||
423 | |||
424 | #ifdef CONFIG_BLK_DEV_INITRD | 424 | #ifdef CONFIG_BLK_DEV_INITRD |
425 | /** | 425 | /** |
426 | * early_init_dt_check_for_initrd - Decode initrd location from flat tree | 426 | * early_init_dt_check_for_initrd - Decode initrd location from flat tree |