X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Farch%2Fpowerpc%2Fplatforms%2Fpseries%2Fdlpar.c;fp=kernel%2Farch%2Fpowerpc%2Fplatforms%2Fpseries%2Fdlpar.c;h=f244dcb4f2cf01c35e1f1025a01fbaaf866de7b6;hb=e09b41010ba33a20a87472ee821fa407a5b8da36;hp=019d34aaf054bc843d6a2d5ac531e9207e6c42ab;hpb=f93b97fd65072de626c074dbe099a1fff05ce060;p=kvmfornfv.git diff --git a/kernel/arch/powerpc/platforms/pseries/dlpar.c b/kernel/arch/powerpc/platforms/pseries/dlpar.c index 019d34aaf..f244dcb4f 100644 --- a/kernel/arch/powerpc/platforms/pseries/dlpar.c +++ b/kernel/arch/powerpc/platforms/pseries/dlpar.c @@ -18,6 +18,8 @@ #include #include #include + +#include "of_helpers.h" #include "offline_states.h" #include "pseries.h" @@ -244,36 +246,13 @@ cc_error: 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 rc; - dn->parent = derive_parent(dn->full_name); - if (!dn->parent) - return -ENOMEM; + dn->parent = pseries_of_derive_parent(dn->full_name); + if (IS_ERR(dn->parent)) + return PTR_ERR(dn->parent); rc = of_attach_node(dn); if (rc) { @@ -421,10 +400,11 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count) return -ENODEV; dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent); - if (!dn) - return -EINVAL; - of_node_put(parent); + if (!dn) { + dlpar_release_drc(drc_index); + return -EINVAL; + } rc = dlpar_attach_node(dn); if (rc) {