|
@@ -1028,6 +1028,24 @@ int of_parse_phandle_with_args(struct device_node *np, const char *list_name,
|
|
|
}
|
|
|
EXPORT_SYMBOL(of_parse_phandle_with_args);
|
|
|
|
|
|
+#if defined(CONFIG_OF_DYNAMIC)
|
|
|
+static int of_property_notify(int action, struct device_node *np,
|
|
|
+ struct property *prop)
|
|
|
+{
|
|
|
+ struct of_prop_reconfig pr;
|
|
|
+
|
|
|
+ pr.dn = np;
|
|
|
+ pr.prop = prop;
|
|
|
+ return of_reconfig_notify(action, &pr);
|
|
|
+}
|
|
|
+#else
|
|
|
+static int of_property_notify(int action, struct device_node *np,
|
|
|
+ struct property *prop)
|
|
|
+{
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
/**
|
|
|
* prom_add_property - Add a property to a node
|
|
|
*/
|
|
@@ -1035,6 +1053,11 @@ int prom_add_property(struct device_node *np, struct property *prop)
|
|
|
{
|
|
|
struct property **next;
|
|
|
unsigned long flags;
|
|
|
+ int rc;
|
|
|
+
|
|
|
+ rc = of_property_notify(OF_RECONFIG_ADD_PROPERTY, np, prop);
|
|
|
+ if (rc)
|
|
|
+ return rc;
|
|
|
|
|
|
prop->next = NULL;
|
|
|
write_lock_irqsave(&devtree_lock, flags);
|
|
@@ -1072,6 +1095,11 @@ int prom_remove_property(struct device_node *np, struct property *prop)
|
|
|
struct property **next;
|
|
|
unsigned long flags;
|
|
|
int found = 0;
|
|
|
+ int rc;
|
|
|
+
|
|
|
+ rc = of_property_notify(OF_RECONFIG_REMOVE_PROPERTY, np, prop);
|
|
|
+ if (rc)
|
|
|
+ return rc;
|
|
|
|
|
|
write_lock_irqsave(&devtree_lock, flags);
|
|
|
next = &np->properties;
|
|
@@ -1114,7 +1142,11 @@ int prom_update_property(struct device_node *np,
|
|
|
{
|
|
|
struct property **next, *oldprop;
|
|
|
unsigned long flags;
|
|
|
- int found = 0;
|
|
|
+ int rc, found = 0;
|
|
|
+
|
|
|
+ rc = of_property_notify(OF_RECONFIG_UPDATE_PROPERTY, np, newprop);
|
|
|
+ if (rc)
|
|
|
+ return rc;
|
|
|
|
|
|
if (!newprop->name)
|
|
|
return -EINVAL;
|
|
@@ -1160,6 +1192,26 @@ int prom_update_property(struct device_node *np,
|
|
|
* device tree nodes.
|
|
|
*/
|
|
|
|
|
|
+static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain);
|
|
|
+
|
|
|
+int of_reconfig_notifier_register(struct notifier_block *nb)
|
|
|
+{
|
|
|
+ return blocking_notifier_chain_register(&of_reconfig_chain, nb);
|
|
|
+}
|
|
|
+
|
|
|
+int of_reconfig_notifier_unregister(struct notifier_block *nb)
|
|
|
+{
|
|
|
+ return blocking_notifier_chain_unregister(&of_reconfig_chain, nb);
|
|
|
+}
|
|
|
+
|
|
|
+int of_reconfig_notify(unsigned long action, void *p)
|
|
|
+{
|
|
|
+ int rc;
|
|
|
+
|
|
|
+ rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p);
|
|
|
+ return notifier_to_errno(rc);
|
|
|
+}
|
|
|
+
|
|
|
#ifdef CONFIG_PROC_DEVICETREE
|
|
|
static void of_add_proc_dt_entry(struct device_node *dn)
|
|
|
{
|
|
@@ -1179,9 +1231,14 @@ static void of_add_proc_dt_entry(struct device_node *dn)
|
|
|
/**
|
|
|
* of_attach_node - Plug a device node into the tree and global list.
|
|
|
*/
|
|
|
-void of_attach_node(struct device_node *np)
|
|
|
+int of_attach_node(struct device_node *np)
|
|
|
{
|
|
|
unsigned long flags;
|
|
|
+ int rc;
|
|
|
+
|
|
|
+ rc = of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, np);
|
|
|
+ if (rc)
|
|
|
+ return rc;
|
|
|
|
|
|
write_lock_irqsave(&devtree_lock, flags);
|
|
|
np->sibling = np->parent->child;
|
|
@@ -1191,6 +1248,7 @@ void of_attach_node(struct device_node *np)
|
|
|
write_unlock_irqrestore(&devtree_lock, flags);
|
|
|
|
|
|
of_add_proc_dt_entry(np);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
#ifdef CONFIG_PROC_DEVICETREE
|
|
@@ -1220,23 +1278,28 @@ static void of_remove_proc_dt_entry(struct device_node *dn)
|
|
|
* The caller must hold a reference to the node. The memory associated with
|
|
|
* the node is not freed until its refcount goes to zero.
|
|
|
*/
|
|
|
-void of_detach_node(struct device_node *np)
|
|
|
+int of_detach_node(struct device_node *np)
|
|
|
{
|
|
|
struct device_node *parent;
|
|
|
unsigned long flags;
|
|
|
+ int rc = 0;
|
|
|
+
|
|
|
+ rc = of_reconfig_notify(OF_RECONFIG_DETACH_NODE, np);
|
|
|
+ if (rc)
|
|
|
+ return rc;
|
|
|
|
|
|
write_lock_irqsave(&devtree_lock, flags);
|
|
|
|
|
|
if (of_node_check_flag(np, OF_DETACHED)) {
|
|
|
/* someone already detached it */
|
|
|
write_unlock_irqrestore(&devtree_lock, flags);
|
|
|
- return;
|
|
|
+ return rc;
|
|
|
}
|
|
|
|
|
|
parent = np->parent;
|
|
|
if (!parent) {
|
|
|
write_unlock_irqrestore(&devtree_lock, flags);
|
|
|
- return;
|
|
|
+ return rc;
|
|
|
}
|
|
|
|
|
|
if (allnodes == np)
|
|
@@ -1265,6 +1328,7 @@ void of_detach_node(struct device_node *np)
|
|
|
write_unlock_irqrestore(&devtree_lock, flags);
|
|
|
|
|
|
of_remove_proc_dt_entry(np);
|
|
|
+ return rc;
|
|
|
}
|
|
|
#endif /* defined(CONFIG_OF_DYNAMIC) */
|
|
|
|