of/reconfig: Always use the same structure for notifiers
[firefly-linux-kernel-4.4.55.git] / drivers / of / dynamic.c
index 80269dc4fe52cb5ab646f413b79f96c79ae3d91f..bf3e53e243a1aa93fbeb15cbb62067964067d0b6 100644 (file)
@@ -74,10 +74,37 @@ int of_reconfig_notifier_unregister(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(of_reconfig_notifier_unregister);
 
-int of_reconfig_notify(unsigned long action, void *p)
+#ifdef DEBUG
+const char *action_names[] = {
+       [OF_RECONFIG_ATTACH_NODE] = "ATTACH_NODE",
+       [OF_RECONFIG_DETACH_NODE] = "DETACH_NODE",
+       [OF_RECONFIG_ADD_PROPERTY] = "ADD_PROPERTY",
+       [OF_RECONFIG_REMOVE_PROPERTY] = "REMOVE_PROPERTY",
+       [OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY",
+};
+#endif
+
+int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p)
 {
        int rc;
+#ifdef DEBUG
+       struct of_reconfig_data *pr = p;
+
+       switch (action) {
+       case OF_RECONFIG_ATTACH_NODE:
+       case OF_RECONFIG_DETACH_NODE:
+               pr_debug("of/notify %-15s %s\n", action_names[action],
+                       pr->dn->full_name);
+               break;
+       case OF_RECONFIG_ADD_PROPERTY:
+       case OF_RECONFIG_REMOVE_PROPERTY:
+       case OF_RECONFIG_UPDATE_PROPERTY:
+               pr_debug("of/notify %-15s %s:%s\n", action_names[action],
+                       pr->dn->full_name, pr->prop->name);
+               break;
 
+       }
+#endif
        rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p);
        return notifier_to_errno(rc);
 }
@@ -91,31 +118,22 @@ int of_reconfig_notify(unsigned long action, void *p)
  * Returns 0 on device going from enabled to disabled, 1 on device
  * going from disabled to enabled and -1 on no change.
  */
-int of_reconfig_get_state_change(unsigned long action, void *arg)
+int of_reconfig_get_state_change(unsigned long action, struct of_reconfig_data *pr)
 {
-       struct device_node *dn;
-       struct property *prop, *old_prop;
-       struct of_prop_reconfig *pr;
+       struct property *prop, *old_prop = NULL;
        int is_status, status_state, old_status_state, prev_state, new_state;
 
        /* figure out if a device should be created or destroyed */
-       dn = NULL;
-       prop = old_prop = NULL;
        switch (action) {
        case OF_RECONFIG_ATTACH_NODE:
        case OF_RECONFIG_DETACH_NODE:
-               dn = arg;
-               prop = of_find_property(dn, "status", NULL);
+               prop = of_find_property(pr->dn, "status", NULL);
                break;
        case OF_RECONFIG_ADD_PROPERTY:
        case OF_RECONFIG_REMOVE_PROPERTY:
-               pr = arg;
-               dn = pr->dn;
                prop = pr->prop;
                break;
        case OF_RECONFIG_UPDATE_PROPERTY:
-               pr = arg;
-               dn = pr->dn;
                prop = pr->prop;
                old_prop = pr->old_prop;
                break;
@@ -181,7 +199,7 @@ EXPORT_SYMBOL_GPL(of_reconfig_get_state_change);
 int of_property_notify(int action, struct device_node *np,
                       struct property *prop, struct property *oldprop)
 {
-       struct of_prop_reconfig pr;
+       struct of_reconfig_data pr;
 
        /* only call notifiers if the node is attached */
        if (!of_node_is_attached(np))
@@ -221,8 +239,12 @@ void __of_attach_node(struct device_node *np)
  */
 int of_attach_node(struct device_node *np)
 {
+       struct of_reconfig_data rd;
        unsigned long flags;
 
+       memset(&rd, 0, sizeof(rd));
+       rd.dn = np;
+
        mutex_lock(&of_mutex);
        raw_spin_lock_irqsave(&devtree_lock, flags);
        __of_attach_node(np);
@@ -231,7 +253,7 @@ int of_attach_node(struct device_node *np)
        __of_attach_node_sysfs(np);
        mutex_unlock(&of_mutex);
 
-       of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, np);
+       of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, &rd);
 
        return 0;
 }
@@ -280,9 +302,13 @@ void __of_detach_node(struct device_node *np)
  */
 int of_detach_node(struct device_node *np)
 {
+       struct of_reconfig_data rd;
        unsigned long flags;
        int rc = 0;
 
+       memset(&rd, 0, sizeof(rd));
+       rd.dn = np;
+
        mutex_lock(&of_mutex);
        raw_spin_lock_irqsave(&devtree_lock, flags);
        __of_detach_node(np);
@@ -291,7 +317,7 @@ int of_detach_node(struct device_node *np)
        __of_detach_node_sysfs(np);
        mutex_unlock(&of_mutex);
 
-       of_reconfig_notify(OF_RECONFIG_DETACH_NODE, np);
+       of_reconfig_notify(OF_RECONFIG_DETACH_NODE, &rd);
 
        return rc;
 }
@@ -423,27 +449,15 @@ static void __of_changeset_entry_dump(struct of_changeset_entry *ce)
 {
        switch (ce->action) {
        case OF_RECONFIG_ADD_PROPERTY:
-               pr_debug("%p: %s %s/%s\n",
-                       ce, "ADD_PROPERTY   ", ce->np->full_name,
-                       ce->prop->name);
-               break;
        case OF_RECONFIG_REMOVE_PROPERTY:
-               pr_debug("%p: %s %s/%s\n",
-                       ce, "REMOVE_PROPERTY", ce->np->full_name,
-                       ce->prop->name);
-               break;
        case OF_RECONFIG_UPDATE_PROPERTY:
-               pr_debug("%p: %s %s/%s\n",
-                       ce, "UPDATE_PROPERTY", ce->np->full_name,
-                       ce->prop->name);
+               pr_debug("of/cset<%p> %-15s %s/%s\n", ce, action_names[ce->action],
+                       ce->np->full_name, ce->prop->name);
                break;
        case OF_RECONFIG_ATTACH_NODE:
-               pr_debug("%p: %s %s\n",
-                       ce, "ATTACH_NODE    ", ce->np->full_name);
-               break;
        case OF_RECONFIG_DETACH_NODE:
-               pr_debug("%p: %s %s\n",
-                       ce, "DETACH_NODE    ", ce->np->full_name);
+               pr_debug("of/cset<%p> %-15s %s\n", ce, action_names[ce->action],
+                       ce->np->full_name);
                break;
        }
 }
@@ -481,6 +495,7 @@ static void __of_changeset_entry_invert(struct of_changeset_entry *ce,
 
 static void __of_changeset_entry_notify(struct of_changeset_entry *ce, bool revert)
 {
+       struct of_reconfig_data rd;
        struct of_changeset_entry ce_inverted;
        int ret;
 
@@ -492,7 +507,9 @@ static void __of_changeset_entry_notify(struct of_changeset_entry *ce, bool reve
        switch (ce->action) {
        case OF_RECONFIG_ATTACH_NODE:
        case OF_RECONFIG_DETACH_NODE:
-               ret = of_reconfig_notify(ce->action, ce->np);
+               memset(&rd, 0, sizeof(rd));
+               rd.dn = ce->np;
+               ret = of_reconfig_notify(ce->action, &rd);
                break;
        case OF_RECONFIG_ADD_PROPERTY:
        case OF_RECONFIG_REMOVE_PROPERTY: