2 * Procedures for creating, accessing and interpreting the device tree.
4 * Paul Mackerras August 1996.
5 * Copyright (C) 1996-2005 Paul Mackerras.
7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
8 * {engebret|bergner}@us.ibm.com
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
17 #include <linux/kernel.h>
18 #include <linux/string.h>
19 #include <linux/init.h>
20 #include <linux/threads.h>
21 #include <linux/spinlock.h>
22 #include <linux/types.h>
23 #include <linux/pci.h>
24 #include <linux/stringify.h>
25 #include <linux/delay.h>
26 #include <linux/initrd.h>
27 #include <linux/bitops.h>
28 #include <linux/module.h>
29 #include <linux/kexec.h>
30 #include <linux/debugfs.h>
31 #include <linux/irq.h>
32 #include <linux/lmb.h>
36 #include <asm/processor.h>
39 #include <asm/system.h>
41 #include <asm/pgtable.h>
42 #include <asm/sections.h>
43 #include <asm/pci-bridge.h>
45 static int __initdata dt_root_addr_cells;
46 static int __initdata dt_root_size_cells;
50 /* export that to outside world */
51 struct device_node *of_chosen;
54 * This function is used to scan the flattened device-tree, it is
55 * used to extract the memory informations at boot before we can
58 int __init of_scan_flat_dt(int (*it)(unsigned long node,
59 const char *uname, int depth,
63 unsigned long p = ((unsigned long)initial_boot_params) +
64 initial_boot_params->off_dt_struct;
69 u32 tag = *((u32 *)p);
73 if (tag == OF_DT_END_NODE) {
81 if (tag == OF_DT_PROP) {
84 if (initial_boot_params->version < 0x10)
85 p = _ALIGN(p, sz >= 8 ? 8 : 4);
90 if (tag != OF_DT_BEGIN_NODE) {
91 printk(KERN_WARNING "Invalid tag %x scanning flattened"
92 " device tree !\n", tag);
97 p = _ALIGN(p + strlen(pathp) + 1, 4);
98 if ((*pathp) == '/') {
100 for (lp = NULL, np = pathp; *np; np++)
106 rc = it(p, pathp, depth, data);
114 unsigned long __init of_get_flat_dt_root(void)
116 unsigned long p = ((unsigned long)initial_boot_params) +
117 initial_boot_params->off_dt_struct;
119 while (*((u32 *)p) == OF_DT_NOP)
121 BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
123 return _ALIGN(p + strlen((char *)p) + 1, 4);
127 * This function can be used within scan_flattened_dt callback to get
128 * access to properties
130 void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
133 unsigned long p = node;
136 u32 tag = *((u32 *)p);
141 if (tag == OF_DT_NOP)
143 if (tag != OF_DT_PROP)
147 noff = *((u32 *)(p + 4));
149 if (initial_boot_params->version < 0x10)
150 p = _ALIGN(p, sz >= 8 ? 8 : 4);
152 nstr = find_flat_dt_string(noff);
154 printk(KERN_WARNING "Can't find property index"
158 if (strcmp(name, nstr) == 0) {
168 int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
171 unsigned long cplen, l;
173 cp = of_get_flat_dt_prop(node, "compatible", &cplen);
177 if (strncasecmp(cp, compat, strlen(compat)) == 0)
187 static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
192 *mem = _ALIGN(*mem, align);
199 static unsigned long __init unflatten_dt_node(unsigned long mem,
201 struct device_node *dad,
202 struct device_node ***allnextpp,
203 unsigned long fpsize)
205 struct device_node *np;
206 struct property *pp, **prev_pp = NULL;
209 unsigned int l, allocl;
213 tag = *((u32 *)(*p));
214 if (tag != OF_DT_BEGIN_NODE) {
215 printk("Weird tag at start of node: %x\n", tag);
220 l = allocl = strlen(pathp) + 1;
221 *p = _ALIGN(*p + l, 4);
223 /* version 0x10 has a more compact unit name here instead of the full
224 * path. we accumulate the full path size using "fpsize", we'll rebuild
225 * it later. We detect this because the first character of the name is
228 if ((*pathp) != '/') {
231 /* root node: special case. fpsize accounts for path
232 * plus terminating zero. root node only has '/', so
233 * fpsize should be 2, but we want to avoid the first
234 * level nodes to have two '/' so we use fpsize 1 here
239 /* account for '/' and path size minus terminal 0
247 np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
248 __alignof__(struct device_node));
250 memset(np, 0, sizeof(*np));
251 np->full_name = ((char *)np) + sizeof(struct device_node);
253 char *p2 = np->full_name;
254 /* rebuild full path for new format */
255 if (dad && dad->parent) {
256 strcpy(p2, dad->full_name);
258 if ((strlen(p2) + l + 1) != allocl) {
259 pr_debug("%s: p: %d, l: %d, a: %d\n",
260 pathp, (int)strlen(p2),
267 memcpy(p2, pathp, l);
269 memcpy(np->full_name, pathp, l);
270 prev_pp = &np->properties;
272 *allnextpp = &np->allnext;
275 /* we temporarily use the next field as `last_child'*/
276 if (dad->next == NULL)
279 dad->next->sibling = np;
282 kref_init(&np->kref);
288 tag = *((u32 *)(*p));
289 if (tag == OF_DT_NOP) {
293 if (tag != OF_DT_PROP)
297 noff = *((u32 *)((*p) + 4));
299 if (initial_boot_params->version < 0x10)
300 *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
302 pname = find_flat_dt_string(noff);
305 "Can't find property name in list !\n");
308 if (strcmp(pname, "name") == 0)
310 l = strlen(pname) + 1;
311 pp = unflatten_dt_alloc(&mem, sizeof(struct property),
312 __alignof__(struct property));
314 if (strcmp(pname, "linux,phandle") == 0) {
315 np->node = *((u32 *)*p);
316 if (np->linux_phandle == 0)
317 np->linux_phandle = np->node;
319 if (strcmp(pname, "ibm,phandle") == 0)
320 np->linux_phandle = *((u32 *)*p);
323 pp->value = (void *)*p;
327 *p = _ALIGN((*p) + sz, 4);
329 /* with version 0x10 we may not have the name property, recreate
330 * it here from the unit name if absent
333 char *p1 = pathp, *ps = pathp, *pa = NULL;
346 pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
347 __alignof__(struct property));
354 memcpy(pp->value, ps, sz - 1);
355 ((char *)pp->value)[sz - 1] = 0;
356 pr_debug("fixed up name for %s -> %s\n", pathp,
362 np->name = of_get_property(np, "name", NULL);
363 np->type = of_get_property(np, "device_type", NULL);
370 while (tag == OF_DT_BEGIN_NODE) {
371 mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
372 tag = *((u32 *)(*p));
374 if (tag != OF_DT_END_NODE) {
375 printk(KERN_INFO "Weird tag at end of node: %x\n", tag);
383 * unflattens the device-tree passed by the firmware, creating the
384 * tree of struct device_node. It also fills the "name" and "type"
385 * pointers of the nodes so the normal device-tree walking functions
386 * can be used (this used to be done by finish_device_tree)
388 void __init unflatten_device_tree(void)
390 unsigned long start, mem, size;
391 struct device_node **allnextp = &allnodes;
393 pr_debug(" -> unflatten_device_tree()\n");
395 /* First pass, scan for size */
396 start = ((unsigned long)initial_boot_params) +
397 initial_boot_params->off_dt_struct;
398 size = unflatten_dt_node(0, &start, NULL, NULL, 0);
399 size = (size | 3) + 1;
401 pr_debug(" size is %lx, allocating...\n", size);
403 /* Allocate memory for the expanded device tree */
404 mem = lmb_alloc(size + 4, __alignof__(struct device_node));
405 mem = (unsigned long) __va(mem);
407 ((u32 *)mem)[size / 4] = 0xdeadbeef;
409 pr_debug(" unflattening %lx...\n", mem);
411 /* Second pass, do actual unflattening */
412 start = ((unsigned long)initial_boot_params) +
413 initial_boot_params->off_dt_struct;
414 unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
415 if (*((u32 *)start) != OF_DT_END)
416 printk(KERN_WARNING "Weird tag at end of tree: %08x\n",
418 if (((u32 *)mem)[size / 4] != 0xdeadbeef)
419 printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
420 ((u32 *)mem)[size / 4]);
423 /* Get pointer to OF "/chosen" node for use everywhere */
424 of_chosen = of_find_node_by_path("/chosen");
425 if (of_chosen == NULL)
426 of_chosen = of_find_node_by_path("/chosen@0");
428 pr_debug(" <- unflatten_device_tree()\n");
431 #define early_init_dt_scan_drconf_memory(node) 0
433 static int __init early_init_dt_scan_cpus(unsigned long node,
434 const char *uname, int depth,
437 static int logical_cpuid;
438 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
443 /* We are scanning "cpu" nodes only */
444 if (type == NULL || strcmp(type, "cpu") != 0)
447 /* Get physical cpuid */
448 intserv = of_get_flat_dt_prop(node, "reg", NULL);
452 * Now see if any of these threads match our boot cpu.
453 * NOTE: This must match the parsing done in smp_setup_cpu_maps.
455 for (i = 0; i < nthreads; i++) {
457 * version 2 of the kexec param format adds the phys cpuid of
460 if (initial_boot_params && initial_boot_params->version >= 2) {
462 initial_boot_params->boot_cpuid_phys) {
468 * Check if it's the boot-cpu, set it's hw index now,
469 * unfortunately this format did not support booting
470 * off secondary threads.
472 if (of_get_flat_dt_prop(node,
473 "linux,boot-cpu", NULL) != NULL) {
480 /* logical cpu id is always 0 on UP kernels */
486 pr_debug("boot cpu: logical %d physical %d\n", logical_cpuid,
488 boot_cpuid = logical_cpuid;
494 #ifdef CONFIG_BLK_DEV_INITRD
495 static void __init early_init_dt_check_for_initrd(unsigned long node)
500 pr_debug("Looking for initrd properties... ");
502 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
504 initrd_start = (unsigned long)
505 __va((u32)of_read_ulong(prop, l/4));
507 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
509 initrd_end = (unsigned long)
510 __va((u32)of_read_ulong(prop, 1/4));
511 initrd_below_start_ok = 1;
517 pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n",
518 initrd_start, initrd_end);
521 static inline void early_init_dt_check_for_initrd(unsigned long node)
524 #endif /* CONFIG_BLK_DEV_INITRD */
526 static int __init early_init_dt_scan_chosen(unsigned long node,
527 const char *uname, int depth, void *data)
532 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
535 (strcmp(uname, "chosen") != 0 &&
536 strcmp(uname, "chosen@0") != 0))
540 lprop = (u64 *)of_get_flat_dt_prop(node,
541 "linux,crashkernel-base", NULL);
543 crashk_res.start = *lprop;
545 lprop = (u64 *)of_get_flat_dt_prop(node,
546 "linux,crashkernel-size", NULL);
548 crashk_res.end = crashk_res.start + *lprop - 1;
551 early_init_dt_check_for_initrd(node);
553 /* Retreive command line */
554 p = of_get_flat_dt_prop(node, "bootargs", &l);
555 if (p != NULL && l > 0)
556 strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
558 #ifdef CONFIG_CMDLINE
559 #ifndef CONFIG_CMDLINE_FORCE
560 if (p == NULL || l == 0 || (l == 1 && (*p) == 0))
562 strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
563 #endif /* CONFIG_CMDLINE */
565 pr_debug("Command line is: %s\n", cmd_line);
571 static int __init early_init_dt_scan_root(unsigned long node,
572 const char *uname, int depth, void *data)
579 prop = of_get_flat_dt_prop(node, "#size-cells", NULL);
580 dt_root_size_cells = (prop == NULL) ? 1 : *prop;
581 pr_debug("dt_root_size_cells = %x\n", dt_root_size_cells);
583 prop = of_get_flat_dt_prop(node, "#address-cells", NULL);
584 dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
585 pr_debug("dt_root_addr_cells = %x\n", dt_root_addr_cells);
591 static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
596 return of_read_number(p, s);
599 static int __init early_init_dt_scan_memory(unsigned long node,
600 const char *uname, int depth, void *data)
602 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
606 /* Look for the ibm,dynamic-reconfiguration-memory node */
608 strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0)
609 return early_init_dt_scan_drconf_memory(node);
611 /* We are scanning "memory" nodes only */
614 * The longtrail doesn't have a device_type on the
615 * /memory node, so look for the node called /memory@0.
617 if (depth != 1 || strcmp(uname, "memory@0") != 0)
619 } else if (strcmp(type, "memory") != 0)
622 reg = (cell_t *)of_get_flat_dt_prop(node, "linux,usable-memory", &l);
624 reg = (cell_t *)of_get_flat_dt_prop(node, "reg", &l);
628 endp = reg + (l / sizeof(cell_t));
630 pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",
631 uname, l, reg[0], reg[1], reg[2], reg[3]);
633 while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
636 base = dt_mem_next_cell(dt_root_addr_cells, ®);
637 size = dt_mem_next_cell(dt_root_size_cells, ®);
641 pr_debug(" - %llx , %llx\n", (unsigned long long)base,
642 (unsigned long long)size);
649 #ifdef CONFIG_PHYP_DUMP
651 * phyp_dump_calculate_reserve_size() - reserve variable boot area 5% or arg
653 * Function to find the largest size we need to reserve
654 * during early boot process.
656 * It either looks for boot param and returns that OR
657 * returns larger of 256 or 5% rounded down to multiples of 256MB.
660 static inline unsigned long phyp_dump_calculate_reserve_size(void)
664 if (phyp_dump_info->reserve_bootvar)
665 return phyp_dump_info->reserve_bootvar;
667 /* divide by 20 to get 5% of value */
668 tmp = lmb_end_of_DRAM();
671 /* round it down in multiples of 256 */
672 tmp = tmp & ~0x0FFFFFFFUL;
674 return (tmp > PHYP_DUMP_RMR_END ? tmp : PHYP_DUMP_RMR_END);
678 * phyp_dump_reserve_mem() - reserve all not-yet-dumped mmemory
680 * This routine may reserve memory regions in the kernel only
681 * if the system is supported and a dump was taken in last
682 * boot instance or if the hardware is supported and the
683 * scratch area needs to be setup. In other instances it returns
684 * without reserving anything. The memory in case of dump being
685 * active is freed when the dump is collected (by userland tools).
687 static void __init phyp_dump_reserve_mem(void)
689 unsigned long base, size;
690 unsigned long variable_reserve_size;
692 if (!phyp_dump_info->phyp_dump_configured) {
693 printk(KERN_ERR "Phyp-dump not supported on this hardware\n");
697 if (!phyp_dump_info->phyp_dump_at_boot) {
698 printk(KERN_INFO "Phyp-dump disabled at boot time\n");
702 variable_reserve_size = phyp_dump_calculate_reserve_size();
704 if (phyp_dump_info->phyp_dump_is_active) {
705 /* Reserve *everything* above RMR.Area freed by userland tools*/
706 base = variable_reserve_size;
707 size = lmb_end_of_DRAM() - base;
709 /* XXX crashed_ram_end is wrong, since it may be beyond
710 * the memory_limit, it will need to be adjusted. */
711 lmb_reserve(base, size);
713 phyp_dump_info->init_reserve_start = base;
714 phyp_dump_info->init_reserve_size = size;
716 size = phyp_dump_info->cpu_state_size +
717 phyp_dump_info->hpte_region_size +
718 variable_reserve_size;
719 base = lmb_end_of_DRAM() - size;
720 lmb_reserve(base, size);
721 phyp_dump_info->init_reserve_start = base;
722 phyp_dump_info->init_reserve_size = size;
726 static inline void __init phyp_dump_reserve_mem(void) {}
727 #endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */
729 #ifdef CONFIG_EARLY_PRINTK
730 /* MS this is Microblaze specifig function */
731 static int __init early_init_dt_scan_serial(unsigned long node,
732 const char *uname, int depth, void *data)
738 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
740 /* find all serial nodes */
741 if (strncmp(uname, "serial", 6) != 0)
744 early_init_dt_check_for_initrd(node);
746 /* find compatible node with uartlite */
747 p = of_get_flat_dt_prop(node, "compatible", &l);
748 if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) &&
749 (strncmp(p, "xlnx,opb-uartlite", 17) != 0))
752 addr = of_get_flat_dt_prop(node, "reg", &l);
753 return *addr; /* return address */
756 /* this function is looking for early uartlite console - Microblaze specific */
757 int __init early_uartlite_console(void)
759 return of_scan_flat_dt(early_init_dt_scan_serial, NULL);
763 void __init early_init_devtree(void *params)
765 pr_debug(" -> early_init_devtree(%p)\n", params);
767 /* Setup flat device-tree pointer */
768 initial_boot_params = params;
770 #ifdef CONFIG_PHYP_DUMP
771 /* scan tree to see if dump occured during last boot */
772 of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL);
775 /* Retrieve various informations from the /chosen node of the
776 * device-tree, including the platform type, initrd location and
777 * size, TCE reserve, and more ...
779 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
781 /* Scan memory nodes and rebuild LMBs */
783 of_scan_flat_dt(early_init_dt_scan_root, NULL);
784 of_scan_flat_dt(early_init_dt_scan_memory, NULL);
786 /* Save command line for /proc/cmdline and then parse parameters */
787 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
792 pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size());
794 pr_debug("Scanning CPUs ...\n");
796 /* Retreive CPU related informations from the flat tree
797 * (altivec support, boot CPU ID, ...)
799 of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
801 pr_debug(" <- early_init_devtree()\n");
805 * Indicates whether the root node has a given value in its
806 * compatible property.
808 int machine_is_compatible(const char *compat)
810 struct device_node *root;
813 root = of_find_node_by_path("/");
815 rc = of_device_is_compatible(root, compat);
820 EXPORT_SYMBOL(machine_is_compatible);
824 * New implementation of the OF "find" APIs, return a refcounted
825 * object, call of_node_put() when done. The device tree and list
826 * are protected by a rw_lock.
828 * Note that property management will need some locking as well,
829 * this isn't dealt with yet.
834 * of_find_node_by_phandle - Find a node given a phandle
835 * @handle: phandle of the node to find
837 * Returns a node pointer with refcount incremented, use
838 * of_node_put() on it when done.
840 struct device_node *of_find_node_by_phandle(phandle handle)
842 struct device_node *np;
844 read_lock(&devtree_lock);
845 for (np = allnodes; np != NULL; np = np->allnext)
846 if (np->linux_phandle == handle)
849 read_unlock(&devtree_lock);
852 EXPORT_SYMBOL(of_find_node_by_phandle);
855 * of_node_get - Increment refcount of a node
856 * @node: Node to inc refcount, NULL is supported to
857 * simplify writing of callers
861 struct device_node *of_node_get(struct device_node *node)
864 kref_get(&node->kref);
867 EXPORT_SYMBOL(of_node_get);
869 static inline struct device_node *kref_to_device_node(struct kref *kref)
871 return container_of(kref, struct device_node, kref);
875 * of_node_release - release a dynamically allocated node
876 * @kref: kref element of the node to be released
878 * In of_node_put() this function is passed to kref_put()
881 static void of_node_release(struct kref *kref)
883 struct device_node *node = kref_to_device_node(kref);
884 struct property *prop = node->properties;
886 /* We should never be releasing nodes that haven't been detached. */
887 if (!of_node_check_flag(node, OF_DETACHED)) {
888 printk(KERN_INFO "WARNING: Bad of_node_put() on %s\n",
891 kref_init(&node->kref);
895 if (!of_node_check_flag(node, OF_DYNAMIC))
899 struct property *next = prop->next;
906 prop = node->deadprops;
907 node->deadprops = NULL;
910 kfree(node->full_name);
916 * of_node_put - Decrement refcount of a node
917 * @node: Node to dec refcount, NULL is supported to
918 * simplify writing of callers
921 void of_node_put(struct device_node *node)
924 kref_put(&node->kref, of_node_release);
926 EXPORT_SYMBOL(of_node_put);
929 * Plug a device node into the tree and global list.
931 void of_attach_node(struct device_node *np)
935 write_lock_irqsave(&devtree_lock, flags);
936 np->sibling = np->parent->child;
937 np->allnext = allnodes;
938 np->parent->child = np;
940 write_unlock_irqrestore(&devtree_lock, flags);
944 * "Unplug" a node from the device tree. The caller must hold
945 * a reference to the node. The memory associated with the node
946 * is not freed until its refcount goes to zero.
948 void of_detach_node(struct device_node *np)
950 struct device_node *parent;
953 write_lock_irqsave(&devtree_lock, flags);
960 allnodes = np->allnext;
962 struct device_node *prev;
963 for (prev = allnodes;
965 prev = prev->allnext)
967 prev->allnext = np->allnext;
970 if (parent->child == np)
971 parent->child = np->sibling;
973 struct device_node *prevsib;
974 for (prevsib = np->parent->child;
975 prevsib->sibling != np;
976 prevsib = prevsib->sibling)
978 prevsib->sibling = np->sibling;
981 of_node_set_flag(np, OF_DETACHED);
984 write_unlock_irqrestore(&devtree_lock, flags);
988 * Add a property to a node
990 int prom_add_property(struct device_node *np, struct property *prop)
992 struct property **next;
996 write_lock_irqsave(&devtree_lock, flags);
997 next = &np->properties;
999 if (strcmp(prop->name, (*next)->name) == 0) {
1000 /* duplicate ! don't insert it */
1001 write_unlock_irqrestore(&devtree_lock, flags);
1004 next = &(*next)->next;
1007 write_unlock_irqrestore(&devtree_lock, flags);
1009 #ifdef CONFIG_PROC_DEVICETREE
1010 /* try to add to proc as well if it was initialized */
1012 proc_device_tree_add_prop(np->pde, prop);
1013 #endif /* CONFIG_PROC_DEVICETREE */
1019 * Remove a property from a node. Note that we don't actually
1020 * remove it, since we have given out who-knows-how-many pointers
1021 * to the data using get-property. Instead we just move the property
1022 * to the "dead properties" list, so it won't be found any more.
1024 int prom_remove_property(struct device_node *np, struct property *prop)
1026 struct property **next;
1027 unsigned long flags;
1030 write_lock_irqsave(&devtree_lock, flags);
1031 next = &np->properties;
1033 if (*next == prop) {
1034 /* found the node */
1036 prop->next = np->deadprops;
1037 np->deadprops = prop;
1041 next = &(*next)->next;
1043 write_unlock_irqrestore(&devtree_lock, flags);
1048 #ifdef CONFIG_PROC_DEVICETREE
1049 /* try to remove the proc node as well */
1051 proc_device_tree_remove_prop(np->pde, prop);
1052 #endif /* CONFIG_PROC_DEVICETREE */
1058 * Update a property in a node. Note that we don't actually
1059 * remove it, since we have given out who-knows-how-many pointers
1060 * to the data using get-property. Instead we just move the property
1061 * to the "dead properties" list, and add the new property to the
1064 int prom_update_property(struct device_node *np,
1065 struct property *newprop,
1066 struct property *oldprop)
1068 struct property **next;
1069 unsigned long flags;
1072 write_lock_irqsave(&devtree_lock, flags);
1073 next = &np->properties;
1075 if (*next == oldprop) {
1076 /* found the node */
1077 newprop->next = oldprop->next;
1079 oldprop->next = np->deadprops;
1080 np->deadprops = oldprop;
1084 next = &(*next)->next;
1086 write_unlock_irqrestore(&devtree_lock, flags);
1091 #ifdef CONFIG_PROC_DEVICETREE
1092 /* try to add to proc as well if it was initialized */
1094 proc_device_tree_update_prop(np->pde, newprop, oldprop);
1095 #endif /* CONFIG_PROC_DEVICETREE */
1100 #if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
1101 static struct debugfs_blob_wrapper flat_dt_blob;
1103 static int __init export_flat_device_tree(void)
1107 flat_dt_blob.data = initial_boot_params;
1108 flat_dt_blob.size = initial_boot_params->totalsize;
1110 d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
1111 of_debugfs_root, &flat_dt_blob);
1117 device_initcall(export_flat_device_tree);