[ppc64] support for runtime updates of /proc/device-tree, from Nathan Lynch --- fs/proc/proc_devtree.c | 39 +++++++++++++++++++++++++++++++-------- include/linux/proc_fs.h | 1 + 2 files changed, 32 insertions(+), 8 deletions(-) diff -puN fs/proc/proc_devtree.c~ppc64-device_tree_updates fs/proc/proc_devtree.c --- 25/fs/proc/proc_devtree.c~ppc64-device_tree_updates 2004-01-13 23:22:01.000000000 -0800 +++ 25-akpm/fs/proc/proc_devtree.c 2004-01-13 23:22:01.000000000 -0800 @@ -11,6 +11,20 @@ #include #include +#ifndef HAVE_ARCH_DEVTREE_FIXUPS +static inline void set_node_proc_entry(struct device_node *np, struct proc_dir_entry *de) +{ +} + +static void inline set_node_name_link(struct device_node *np, struct proc_dir_entry *de) +{ +} + +static void inline set_node_addr_link(struct device_node *np, struct proc_dir_entry *de) +{ +} +#endif + static struct proc_dir_entry *proc_device_tree; /* @@ -44,7 +58,7 @@ static int property_read_proc(char *page /* * Process a node, adding entries for its children and its properties. */ -static void add_node(struct device_node *np, struct proc_dir_entry *de) +void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *de) { struct property *pp; struct proc_dir_entry *ent; @@ -53,6 +67,7 @@ static void add_node(struct device_node int l; struct proc_dir_entry *list, **lastp, *al; + set_node_proc_entry(np, de); lastp = &list; for (pp = np->properties; pp != 0; pp = pp->next) { /* @@ -70,7 +85,8 @@ static void add_node(struct device_node *lastp = ent; lastp = &ent->next; } - for (child = np->child; child != 0; child = child->sibling) { + child = NULL; + while ((child = of_get_next_child(np, child))) { p = strrchr(child->full_name, '/'); if (p == 0) p = child->full_name; @@ -85,7 +101,7 @@ static void add_node(struct device_node break; *lastp = ent; lastp = &ent->next; - add_node(child, ent); + proc_device_tree_add_node(child, ent); /* * If we left the address part on the name, consider @@ -98,26 +114,32 @@ static void add_node(struct device_node * If this is the first node with a given name property, * add a symlink with the name property as its name. */ - for (sib = np->child; sib != child; sib = sib->sibling) + sib = NULL; + while ((sib = of_get_next_child(np, sib)) && sib != child) if (sib->name && strcmp(sib->name, child->name) == 0) break; if (sib == child && strncmp(p, child->name, l) != 0) { al = proc_symlink(child->name, de, ent->name); - if (al == 0) + if (al == 0) { + of_node_put(sib); break; + } + set_node_name_link(child, al); *lastp = al; lastp = &al->next; } - + of_node_put(sib); /* * Add another directory with the @address part as its name. */ al = proc_symlink(at, de, ent->name); if (al == 0) break; + set_node_addr_link(child, al); *lastp = al; lastp = &al->next; } + of_node_put(child); *lastp = 0; de->subdir = list; } @@ -133,10 +155,11 @@ void proc_device_tree_init(void) proc_device_tree = proc_mkdir("device-tree", 0); if (proc_device_tree == 0) return; - root = find_path_device("/"); + root = of_find_node_by_path("/"); if (root == 0) { printk(KERN_ERR "/proc/device-tree: can't find root\n"); return; } - add_node(root, proc_device_tree); + proc_device_tree_add_node(root, proc_device_tree); + of_node_put(root); } diff -puN include/linux/proc_fs.h~ppc64-device_tree_updates include/linux/proc_fs.h --- 25/include/linux/proc_fs.h~ppc64-device_tree_updates 2004-01-13 23:22:01.000000000 -0800 +++ 25-akpm/include/linux/proc_fs.h 2004-01-13 23:22:01.000000000 -0800 @@ -132,6 +132,7 @@ extern void proc_tty_unregister_driver(s * proc_devtree.c */ extern void proc_device_tree_init(void); +extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *); /* * proc_rtas.c _