[PATCH 4/8] PPC64 prom.c: use pSeries reconfig notifier

From: Paul Mackerras
Date: Thu Mar 17 2005 - 07:17:49 EST


Use the pSeries_reconfig notifier list to fix up a device node which
is about to be added.

Signed-off-by: Nathan Lynch <ntl@xxxxxxxxx>
Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>

arch/ppc64/kernel/prom.c | 40 ++++++++++++++++++++-------
1 files changed, 31 insertions(+), 9 deletions(-)

Index: linux-2.6.11-bk10/arch/ppc64/kernel/prom.c
===================================================================
--- linux-2.6.11-bk10.orig/arch/ppc64/kernel/prom.c 2005-03-14 22:15:45.000000000 +0000
+++ linux-2.6.11-bk10/arch/ppc64/kernel/prom.c 2005-03-14 22:28:19.000000000 +0000
@@ -52,6 +52,7 @@
#include <asm/btext.h>
#include <asm/sections.h>
#include <asm/machdep.h>
+#include <asm/pSeries_reconfig.h>

#ifdef DEBUG
#define DBG(fmt...) udbg_printf(fmt)
@@ -1635,15 +1636,6 @@ out:
*/
void of_attach_node(struct device_node *np)
{
- int err;
-
- /* This use of finish_node will be moved to a notifier so
- * the error code can be used.
- */
- err = finish_node(np, NULL, of_finish_dynamic_node, 0, 0, 0);
- if (err < 0)
- return;
-
write_lock(&devtree_lock);
np->sibling = np->parent->child;
np->allnext = allnodes;
@@ -1690,6 +1682,36 @@ void of_detach_node(const struct device_
write_unlock(&devtree_lock);
}

+static int prom_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
+{
+ int err;
+
+ switch (action) {
+ case PSERIES_RECONFIG_ADD:
+ err = finish_node(node, NULL, of_finish_dynamic_node, 0, 0, 0);
+ if (err < 0) {
+ printk(KERN_ERR "finish_node returned %d\n", err);
+ err = NOTIFY_BAD;
+ }
+ break;
+ default:
+ err = NOTIFY_DONE;
+ break;
+ }
+ return err;
+}
+
+static struct notifier_block prom_reconfig_nb = {
+ .notifier_call prom_reconfig_notifier,
+ .priority = 10, /* This one needs to run first */
+};
+
+static int __init prom_reconfig_setup(void)
+{
+ return pSeries_reconfig_notifier_register(&prom_reconfig_nb);
+}
+__initcall(prom_reconfig_setup);
+
/*
* Find a property with a given name for a given node
* and return the value.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/