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

Nathan Lynch ntl at pobox.com
Thu Mar 10 11:51:52 EST 2005


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

Signed-off-by: Nathan Lynch <ntl at pobox.com>

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

Index: linux-2.6.11-bk4/arch/ppc64/kernel/prom.c
===================================================================
--- linux-2.6.11-bk4.orig/arch/ppc64/kernel/prom.c	2005-03-09 04:22:07.000000000 +0000
+++ linux-2.6.11-bk4/arch/ppc64/kernel/prom.c	2005-03-09 06:12:30.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)
@@ -1627,15 +1628,6 @@ out:
  */
 void of_add_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;
@@ -1682,6 +1674,36 @@ void of_remove_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.



More information about the Linuxppc64-dev mailing list