From patchwork Mon Mar 29 15:12:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12170329 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 4A140C433E8 for ; Mon, 29 Mar 2021 15:12:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2604561969 for ; Mon, 29 Mar 2021 15:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbhC2PMT (ORCPT ); Mon, 29 Mar 2021 11:12:19 -0400 Received: from mga05.intel.com ([192.55.52.43]:63003 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbhC2PMG (ORCPT ); Mon, 29 Mar 2021 11:12:06 -0400 IronPort-SDR: 7uU0xg+GgC9gIF08ThzdOejUE1dE5QTljuQ2cO3bVA8fjlsYanXM8RMsoU4DHFW37VFsJmx9m2 51ARlQb3E0XQ== X-IronPort-AV: E=McAfee;i="6000,8403,9938"; a="276730834" X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="276730834" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 08:12:02 -0700 IronPort-SDR: xSUKaYj+AoGcgw9VlJLUci1NBKKxL4WelFvRMAkmhNl7hOVkjtG3V3C0AN63hkm929WW2dJol7 5XGWSbpm+RPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="383599171" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 29 Mar 2021 08:11:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 175E2132; Mon, 29 Mar 2021 18:12:13 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Daniel Scally , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Yong Zhi , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Heikki Krogerus Subject: [PATCH v2 3/6] software node: Deduplicate code in fwnode_create_software_node() Date: Mon, 29 Mar 2021 18:12:04 +0300 Message-Id: <20210329151207.36619-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210329151207.36619-1-andriy.shevchenko@linux.intel.com> References: <20210329151207.36619-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Deduplicate conditional and assignment in fwnode_create_software_node(), i.e. parent is checked in two out of three cases and parent software node is assigned by to_swnode() call. Signed-off-by: Andy Shevchenko Reviewed-by: Daniel Scally --- v2: no changes drivers/base/swnode.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 19aa44bc2628..db982859171e 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -973,15 +973,14 @@ fwnode_create_software_node(const struct property_entry *properties, { struct fwnode_handle *fwnode; struct software_node *node; - struct swnode *p = NULL; - - if (parent) { - if (IS_ERR(parent)) - return ERR_CAST(parent); - if (!is_software_node(parent)) - return ERR_PTR(-EINVAL); - p = to_swnode(parent); - } + struct swnode *p; + + if (IS_ERR(parent)) + return ERR_CAST(parent); + + p = to_swnode(parent); + if (parent && !p) + return ERR_PTR(-EINVAL); node = software_node_alloc(properties); if (IS_ERR(node))