提交 3aef19f0 编写于 作者: A Akinobu Mita 提交者: Benjamin Herrenschmidt

powerpc/pseries: Introduce pSeries_reconfig_notify()

This introduces pSeries_reconfig_notify() as a just wrapper of
blocking_notifier_call_chain() for pSeries_reconfig_chain.

This is a preparation to improvement of error code on reconfiguration
notifier failure.
Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
上级 e48f7eb2
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#ifdef CONFIG_PPC_PSERIES #ifdef CONFIG_PPC_PSERIES
extern int pSeries_reconfig_notifier_register(struct notifier_block *); extern int pSeries_reconfig_notifier_register(struct notifier_block *);
extern void pSeries_reconfig_notifier_unregister(struct notifier_block *); extern void pSeries_reconfig_notifier_unregister(struct notifier_block *);
extern struct blocking_notifier_head pSeries_reconfig_chain; extern int pSeries_reconfig_notify(unsigned long action, void *p);
/* Not the best place to put this, will be fixed when we move some /* Not the best place to put this, will be fixed when we move some
* of the rtas suspend-me stuff to pseries */ * of the rtas suspend-me stuff to pseries */
extern void pSeries_coalesce_init(void); extern void pSeries_coalesce_init(void);
......
...@@ -262,12 +262,11 @@ int dlpar_attach_node(struct device_node *dn) ...@@ -262,12 +262,11 @@ int dlpar_attach_node(struct device_node *dn)
if (!dn->parent) if (!dn->parent)
return -ENOMEM; return -ENOMEM;
rc = blocking_notifier_call_chain(&pSeries_reconfig_chain, rc = pSeries_reconfig_notify(PSERIES_RECONFIG_ADD, dn);
PSERIES_RECONFIG_ADD, dn); if (rc) {
if (rc == NOTIFY_BAD) {
printk(KERN_ERR "Failed to add device node %s\n", printk(KERN_ERR "Failed to add device node %s\n",
dn->full_name); dn->full_name);
return -ENOMEM; /* For now, safe to assume kmalloc failure */ return rc;
} }
of_attach_node(dn); of_attach_node(dn);
...@@ -297,8 +296,7 @@ int dlpar_detach_node(struct device_node *dn) ...@@ -297,8 +296,7 @@ int dlpar_detach_node(struct device_node *dn)
remove_proc_entry(dn->pde->name, parent->pde); remove_proc_entry(dn->pde->name, parent->pde);
#endif #endif
blocking_notifier_call_chain(&pSeries_reconfig_chain, pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE, dn);
PSERIES_RECONFIG_REMOVE, dn);
of_detach_node(dn); of_detach_node(dn);
of_node_put(dn); /* Must decrement the refcount */ of_node_put(dn); /* Must decrement the refcount */
......
...@@ -97,7 +97,7 @@ static struct device_node *derive_parent(const char *path) ...@@ -97,7 +97,7 @@ static struct device_node *derive_parent(const char *path)
return parent; return parent;
} }
BLOCKING_NOTIFIER_HEAD(pSeries_reconfig_chain); static BLOCKING_NOTIFIER_HEAD(pSeries_reconfig_chain);
int pSeries_reconfig_notifier_register(struct notifier_block *nb) int pSeries_reconfig_notifier_register(struct notifier_block *nb)
{ {
...@@ -109,6 +109,16 @@ void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) ...@@ -109,6 +109,16 @@ void pSeries_reconfig_notifier_unregister(struct notifier_block *nb)
blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb); blocking_notifier_chain_unregister(&pSeries_reconfig_chain, nb);
} }
int pSeries_reconfig_notify(unsigned long action, void *p)
{
int err = blocking_notifier_call_chain(&pSeries_reconfig_chain,
action, p);
if (err == NOTIFY_BAD)
return -ENOMEM; /* For now, safe to assume kmalloc failure */
return 0;
}
static int pSeries_reconfig_add_node(const char *path, struct property *proplist) static int pSeries_reconfig_add_node(const char *path, struct property *proplist)
{ {
struct device_node *np; struct device_node *np;
...@@ -132,11 +142,9 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist ...@@ -132,11 +142,9 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
goto out_err; goto out_err;
} }
err = blocking_notifier_call_chain(&pSeries_reconfig_chain, err = pSeries_reconfig_notify(PSERIES_RECONFIG_ADD, np);
PSERIES_RECONFIG_ADD, np); if (err) {
if (err == NOTIFY_BAD) {
printk(KERN_ERR "Failed to add device node %s\n", path); printk(KERN_ERR "Failed to add device node %s\n", path);
err = -ENOMEM; /* For now, safe to assume kmalloc failure */
goto out_err; goto out_err;
} }
...@@ -173,8 +181,7 @@ static int pSeries_reconfig_remove_node(struct device_node *np) ...@@ -173,8 +181,7 @@ static int pSeries_reconfig_remove_node(struct device_node *np)
remove_node_proc_entries(np); remove_node_proc_entries(np);
blocking_notifier_call_chain(&pSeries_reconfig_chain, pSeries_reconfig_notify(PSERIES_RECONFIG_REMOVE, np);
PSERIES_RECONFIG_REMOVE, np);
of_detach_node(np); of_detach_node(np);
of_node_put(parent); of_node_put(parent);
...@@ -472,11 +479,10 @@ static int do_update_property(char *buf, size_t bufsize) ...@@ -472,11 +479,10 @@ static int do_update_property(char *buf, size_t bufsize)
else else
action = PSERIES_DRCONF_MEM_REMOVE; action = PSERIES_DRCONF_MEM_REMOVE;
rc = blocking_notifier_call_chain(&pSeries_reconfig_chain, rc = pSeries_reconfig_notify(action, value);
action, value); if (rc) {
if (rc == NOTIFY_BAD) { prom_update_property(np, oldprop, newprop);
rc = prom_update_property(np, oldprop, newprop); return rc;
return -ENOMEM;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册