From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2023EC3F2D1 for ; Wed, 4 Mar 2020 08:54:07 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C68522166E for ; Wed, 4 Mar 2020 08:54:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HLHhE6NC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C68522166E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48XSNY0nVnzDqN0 for ; Wed, 4 Mar 2020 19:54:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=kernelfans@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=HLHhE6NC; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48XSJH1XxGzDqLj for ; Wed, 4 Mar 2020 19:50:23 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id j20so319485pll.6 for ; Wed, 04 Mar 2020 00:50:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PbAG5DVp5Gwe/RZZ9j0NJf7u8QaXPmkMnI7g6z3JMC8=; b=HLHhE6NC/N2Num6RVigdOSImGbpk3nmwnQlk2QXjsRlmsQbb7rVGbhzCI79qMc4DOQ rglDWly5IB+23fcbexPX5ZL/YTlmfbbs0sQSBT3OtGGzbht8FSMM/0N/jKJBz9IR6Mft QZiGG/6CHHCAh8aYaS72EewgvnynAyu5BPYZDafkeOuc+QMZS0/LtA1iOQ6YeJwVlAHB +TiQ9oCTYHs/jq9NXolGDxQS6ceNp8BSNoKnxWJ/fmMznvgIF+RHwT80CAOmxw9UzcdG kdZXUjK3rCYnuVdHEIxSa3jEVbJoYDLQiBU3aS/swGU618NlhmvsGn1+N1/4xCKFStsW LVcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PbAG5DVp5Gwe/RZZ9j0NJf7u8QaXPmkMnI7g6z3JMC8=; b=Q8IPrUvkLbgWulQJw1b20IRYjKSoS80AEAa7MNCbXd+InIJzqMmWw7+lXm+jjBVYkV BhhQW9KNcl62x1AmY9kvDpePazlI0gKFhPrftpsACi0lh+4IxQnKiKPKMjQIx29WirrJ H3nfnI8XDjTJ9U++nSVmUywvBEryN2YcQC/0RxAfwUr4DPbrbcfnb8Rzu4ZVWB+WOxDc zZqb8a96mPqA2n+PLQuCwBQZ/sxvK7oj9CoYv90hJxZ0Qxn3WrvBUr5dD4iNjPr8mVOs zQdIlgolqf7rBAMJliN9SyoHqtnngVeze1kuHxYd2eX79Wq8/TQgGRM3lP335z3ZwG2Y Cjtg== X-Gm-Message-State: ANhLgQ3CMZuOa5FOGq8XrB6g7EDi85C+AlRdkkX84OUCk3zzlpxa8l9v +xXy8HYLQt8RZDUR2vLAbLtL+hY= X-Google-Smtp-Source: ADFU+vv8xfB2TdqzoYxkWVhmod8311VaLoqVkmOG18qZwQFEIHdrRlKPnLs8enDR1iEXS04WBJve/A== X-Received: by 2002:a17:902:14d:: with SMTP id 71mr2053516plb.162.1583311820610; Wed, 04 Mar 2020 00:50:20 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id v123sm463085pfb.85.2020.03.04.00.50.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2020 00:50:20 -0800 (PST) From: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Subject: [PATCHv3 1/2] powerpc/of: split out new_property() for reusing Date: Wed, 4 Mar 2020 16:47:29 +0800 Message-Id: <1583311651-29310-2-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1583311651-29310-1-git-send-email-kernelfans@gmail.com> References: <1582882895-3142-1-git-send-email-kernelfans@gmail.com> <1583311651-29310-1-git-send-email-kernelfans@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Donnellan , kexec@lists.infradead.org, Pingfan Liu , Rob Herring , Paul Mackerras , "Aneesh Kumar K . V" , Oliver O'Halloran , Dan Williams , Frank Rowand , Hari Bathini Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Splitting out new_property() for coming reusing and moving it to of_helpers.c. Also do some coding style cleanup. Signed-off-by: Pingfan Liu To: linuxppc-dev@lists.ozlabs.org Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Hari Bathini Cc: Aneesh Kumar K.V Cc: Oliver O'Halloran Cc: Dan Williams Cc: Andrew Donnellan Cc: Christophe Leroy Cc: Rob Herring Cc: Frank Rowand Cc: kexec@lists.infradead.org --- arch/powerpc/platforms/pseries/of_helpers.c | 28 ++++++++++++++++++++++++++++ arch/powerpc/platforms/pseries/of_helpers.h | 3 +++ arch/powerpc/platforms/pseries/reconfig.c | 26 -------------------------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c index 66dfd82..1022e0f 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.c +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -7,6 +7,34 @@ #include "of_helpers.h" +struct property *new_property(const char *name, const int length, + const unsigned char *value, struct property *last) +{ + struct property *new = kzalloc(sizeof(*new), GFP_KERNEL); + + if (!new) + return NULL; + + new->name = kstrdup(name, GFP_KERNEL); + if (!new->name) + goto cleanup; + new->value = kmalloc(length + 1, GFP_KERNEL); + if (!new->value) + goto cleanup; + + memcpy(new->value, value, length); + *(((char *)new->value) + length) = 0; + new->length = length; + new->next = last; + return new; + +cleanup: + kfree(new->name); + kfree(new->value); + kfree(new); + return NULL; +} + /** * pseries_of_derive_parent - basically like dirname(1) * @path: the full_name of a node to be added to the tree diff --git a/arch/powerpc/platforms/pseries/of_helpers.h b/arch/powerpc/platforms/pseries/of_helpers.h index decad65..34add82 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.h +++ b/arch/powerpc/platforms/pseries/of_helpers.h @@ -4,6 +4,9 @@ #include +struct property *new_property(const char *name, const int length, + const unsigned char *value, struct property *last); + struct device_node *pseries_of_derive_parent(const char *path); #endif /* _PSERIES_OF_HELPERS_H */ diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index 7f7369f..8e5a2ba 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -165,32 +165,6 @@ static char * parse_next_property(char *buf, char *end, char **name, int *length return tmp; } -static struct property *new_property(const char *name, const int length, - const unsigned char *value, struct property *last) -{ - struct property *new = kzalloc(sizeof(*new), GFP_KERNEL); - - if (!new) - return NULL; - - if (!(new->name = kstrdup(name, GFP_KERNEL))) - goto cleanup; - if (!(new->value = kmalloc(length + 1, GFP_KERNEL))) - goto cleanup; - - memcpy(new->value, value, length); - *(((char *)new->value) + length) = 0; - new->length = length; - new->next = last; - return new; - -cleanup: - kfree(new->name); - kfree(new->value); - kfree(new); - return NULL; -} - static int do_add_node(char *buf, size_t bufsize) { char *path, *end, *name; -- 2.7.5