From patchwork Sat Mar 27 22:20:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 410391 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 0C379C433FB for ; Sat, 27 Mar 2021 22:21:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDCCD619AB for ; Sat, 27 Mar 2021 22:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbhC0WUm (ORCPT ); Sat, 27 Mar 2021 18:20:42 -0400 Received: from mga12.intel.com ([192.55.52.136]:20237 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231192AbhC0WUR (ORCPT ); Sat, 27 Mar 2021 18:20:17 -0400 IronPort-SDR: pM0Dis63SoBZ7fNy4JwA+Gf6AuttayFpCX5qJCu4TfAXG3rLzl55OitmJGpLRZEmsC+POmWO84 CtQmjzwOD2Sw== X-IronPort-AV: E=McAfee;i="6000,8403,9936"; a="170732004" X-IronPort-AV: E=Sophos;i="5.81,284,1610438400"; d="scan'208";a="170732004" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2021 15:20:17 -0700 IronPort-SDR: LkmIsYHL0BkahnxczuekWaqkoWewS8vWFqP55myOp50unfu6GOYYoKajQLSDypCzBBlJKtVTxp oAVFpbAFz3vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,284,1610438400"; d="scan'208";a="417064275" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 27 Mar 2021 15:20:13 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id EB6C26F1; Sun, 28 Mar 2021 00:20:27 +0200 (EET) 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 v1 4/8] software node: Deduplicate code in fwnode_create_software_node() Date: Sun, 28 Mar 2021 00:20:08 +0200 Message-Id: <20210327222012.54103-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210327222012.54103-1-andriy.shevchenko@linux.intel.com> References: <20210327222012.54103-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 --- 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 d7fe1a887d2d..22f81688af2c 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -1100,15 +1100,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))