Commit 40a4a0aa authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ppc64: support for runtime updates of /proc/device-tree, from Nathan Lynch

From: Anton Blanchard <anton@samba.org>

support for runtime updates of /proc/device-tree, from Nathan Lynch
parent aafb9561
...@@ -11,6 +11,20 @@ ...@@ -11,6 +11,20 @@
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#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; static struct proc_dir_entry *proc_device_tree;
/* /*
...@@ -44,7 +58,7 @@ static int property_read_proc(char *page, char **start, off_t off, ...@@ -44,7 +58,7 @@ static int property_read_proc(char *page, char **start, off_t off,
/* /*
* Process a node, adding entries for its children and its properties. * 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 property *pp;
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
...@@ -53,6 +67,7 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de) ...@@ -53,6 +67,7 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de)
int l; int l;
struct proc_dir_entry *list, **lastp, *al; struct proc_dir_entry *list, **lastp, *al;
set_node_proc_entry(np, de);
lastp = &list; lastp = &list;
for (pp = np->properties; pp != 0; pp = pp->next) { for (pp = np->properties; pp != 0; pp = pp->next) {
/* /*
...@@ -70,7 +85,8 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de) ...@@ -70,7 +85,8 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de)
*lastp = ent; *lastp = ent;
lastp = &ent->next; 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, '/'); p = strrchr(child->full_name, '/');
if (p == 0) if (p == 0)
p = child->full_name; p = child->full_name;
...@@ -85,7 +101,7 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de) ...@@ -85,7 +101,7 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de)
break; break;
*lastp = ent; *lastp = ent;
lastp = &ent->next; lastp = &ent->next;
add_node(child, ent); proc_device_tree_add_node(child, ent);
/* /*
* If we left the address part on the name, consider * If we left the address part on the name, consider
...@@ -98,26 +114,32 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de) ...@@ -98,26 +114,32 @@ static void add_node(struct device_node *np, struct proc_dir_entry *de)
* If this is the first node with a given name property, * If this is the first node with a given name property,
* add a symlink with the name property as its name. * 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) if (sib->name && strcmp(sib->name, child->name) == 0)
break; break;
if (sib == child && strncmp(p, child->name, l) != 0) { if (sib == child && strncmp(p, child->name, l) != 0) {
al = proc_symlink(child->name, de, ent->name); al = proc_symlink(child->name, de, ent->name);
if (al == 0) if (al == 0) {
of_node_put(sib);
break; break;
}
set_node_name_link(child, al);
*lastp = al; *lastp = al;
lastp = &al->next; lastp = &al->next;
} }
of_node_put(sib);
/* /*
* Add another directory with the @address part as its name. * Add another directory with the @address part as its name.
*/ */
al = proc_symlink(at, de, ent->name); al = proc_symlink(at, de, ent->name);
if (al == 0) if (al == 0)
break; break;
set_node_addr_link(child, al);
*lastp = al; *lastp = al;
lastp = &al->next; lastp = &al->next;
} }
of_node_put(child);
*lastp = 0; *lastp = 0;
de->subdir = list; de->subdir = list;
} }
...@@ -133,10 +155,11 @@ void proc_device_tree_init(void) ...@@ -133,10 +155,11 @@ void proc_device_tree_init(void)
proc_device_tree = proc_mkdir("device-tree", 0); proc_device_tree = proc_mkdir("device-tree", 0);
if (proc_device_tree == 0) if (proc_device_tree == 0)
return; return;
root = find_path_device("/"); root = of_find_node_by_path("/");
if (root == 0) { if (root == 0) {
printk(KERN_ERR "/proc/device-tree: can't find root\n"); printk(KERN_ERR "/proc/device-tree: can't find root\n");
return; return;
} }
add_node(root, proc_device_tree); proc_device_tree_add_node(root, proc_device_tree);
of_node_put(root);
} }
...@@ -132,6 +132,7 @@ extern void proc_tty_unregister_driver(struct tty_driver *driver); ...@@ -132,6 +132,7 @@ extern void proc_tty_unregister_driver(struct tty_driver *driver);
* proc_devtree.c * proc_devtree.c
*/ */
extern void proc_device_tree_init(void); extern void proc_device_tree_init(void);
extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
/* /*
* proc_rtas.c * proc_rtas.c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment