From patchwork Tue Aug 4 14:36:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 503633 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 62515140306 for ; Wed, 5 Aug 2015 00:40:15 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 475061A1DEC for ; Wed, 5 Aug 2015 00:40:15 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lists.ozlabs.org (Postfix) with ESMTP id DCA2E1A1C19 for ; Wed, 5 Aug 2015 00:37:08 +1000 (AEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 04 Aug 2015 07:36:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,609,1432623600"; d="scan'208";a="741959130" Received: from black.fi.intel.com ([10.237.72.157]) by orsmga001.jf.intel.com with ESMTP; 04 Aug 2015 07:36:52 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C192E21C; Tue, 4 Aug 2015 17:36:51 +0300 (EEST) From: Andy Shevchenko To: Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Michael Ellerman Subject: [PATCH 5/5] powerpc/pseries: re-use code from of_helpers module Date: Tue, 4 Aug 2015 17:36:49 +0300 Message-Id: <1438699009-112794-5-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1438699009-112794-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1438699009-112794-1-git-send-email-andriy.shevchenko@linux.intel.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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: Andy Shevchenko --- arch/powerpc/platforms/pseries/dlpar.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index 47d9cebe..b7f243c 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/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) {