提交 06bacefc 编写于 作者: A Andy Shevchenko 提交者: Michael Ellerman

powerpc/pseries: re-use code from of_helpers module

The derive_parent() has similar semantics to what we have in newly introduced
of_helpers module. The replacement reduces code base and propagates the actual
error code to the caller.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 a46d9884
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include "of_helpers.h"
#include "offline_states.h" #include "offline_states.h"
#include "pseries.h" #include "pseries.h"
...@@ -244,36 +246,13 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, ...@@ -244,36 +246,13 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
return first_dn; return first_dn;
} }
static struct device_node *derive_parent(const char *path)
{
struct device_node *parent;
char *last_slash;
last_slash = strrchr(path, '/');
if (last_slash == path) {
parent = of_find_node_by_path("/");
} else {
char *parent_path;
int parent_path_len = last_slash - path + 1;
parent_path = kmalloc(parent_path_len, GFP_KERNEL);
if (!parent_path)
return NULL;
strlcpy(parent_path, path, parent_path_len);
parent = of_find_node_by_path(parent_path);
kfree(parent_path);
}
return parent;
}
int dlpar_attach_node(struct device_node *dn) int dlpar_attach_node(struct device_node *dn)
{ {
int rc; int rc;
dn->parent = derive_parent(dn->full_name); dn->parent = pseries_of_derive_parent(dn->full_name);
if (!dn->parent) if (IS_ERR(dn->parent))
return -ENOMEM; return PTR_ERR(dn->parent);
rc = of_attach_node(dn); rc = of_attach_node(dn);
if (rc) { if (rc) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册