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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 443D8C54EAA for ; Mon, 30 Jan 2023 18:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RbJfXB6KPTbwxN6m+56ZvkFi9IcGto77WC6qJvdJe70=; b=lomka7sDvglHbo BXzGvKzsW43mMWihuE7NQB3B+MLkiI+Fd15BIDFMbYcsT/DIb8HHN/KnI6wdl0btGCysppqh8BFhH LJDrspMi/7Q6pcxoVMivGQTm2nkbHEByZQ/T7WgA3avqvMOJJ1NFdZRj2RroTqgT3+0MbfRTIUWF1 ykWnOcwOk74vO/SsrGkURtzTVc6XpuOXT2DG1Khb2nUz3hAb/mFHfzQE6GNSfj0pL+aFi/nSTIxV2 Gf6P629NkCIHAi2tm1JBiSSkiSh7pLotRZm3NFGsh3vFc9rmqL56PzxnwwAxv7jR5dsmbMcXiXDJO ziukAiZx06u8gopkRFvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMYhF-004u8H-PE; Mon, 30 Jan 2023 18:16:03 +0000 Received: from mga09.intel.com ([134.134.136.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMYh4-004u4G-Fd for linux-arm-kernel@lists.infradead.org; Mon, 30 Jan 2023 18:15:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675102550; x=1706638550; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=QjXjMnu6Y3KsGfyiWp4s/PbltUG+5MX/5jw4lyAX9SI=; b=RCaHyeGd+RsLj8X1/PDBICb8xqYatgFjJ7qqsTmjR90mvQr7tggkhnuc cFnOwLIF8oDVhqk2rwZnTeFRPCaH3cyfEiqsEXdGzgHeGfs0Q3kn6Rd00 REtUNfBok8/Fi8SnOoXyNso4JYKilJs5M6U4OpSk12Qj2gfBzSJZhn5az VL/WIMenZWAwKFR04g4APvBBSzk1MT6ZUeX7JJmd6seLrngnqnh7covPf dPlKuqkUZRJu6mbQnoMgXnvrB6uVaWLWJYx4XvsuSYWvthSbnPhSrq3N0 1qnBqWOUn62TMZASdjn1nZyBP2lOO02KcMXr/M9y0Ggc0yStLnQOKPH+z g==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="328909716" X-IronPort-AV: E=Sophos;i="5.97,258,1669104000"; d="scan'208";a="328909716" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 10:15:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="657563974" X-IronPort-AV: E=Sophos;i="5.97,258,1669104000"; d="scan'208";a="657563974" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 10:15:34 -0800 Received: from kekkonen.localdomain (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 9970A1202B0; Mon, 30 Jan 2023 16:39:47 +0200 (EET) Date: Mon, 30 Jan 2023 16:39:47 +0200 From: Sakari Ailus To: Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Sudeep Holla , Cristian Marussi , Linus Walleij , Bartosz Golaszewski , Thomas Gleixner , Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rob Herring , Frank Rowand , Geert Uytterhoeven , Magnus Damm , Len Brown , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Tony Lindgren , Linux Kernel Functional Testing , Naresh Kamboju , Abel Vesa , Alexander Stein , Geert Uytterhoeven , John Stultz , Doug Anderson , Guenter Roeck , Dmitry Baryshkov , Maxim Kiselev , Maxim Kochetkov , Miquel Raynal , Luca Weiss , Colin Foster , Martin Kepplinger , Jean-Philippe Brucker , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v2 09/11] of: property: Simplify of_link_to_phandle() Message-ID: References: <20230127001141.407071-1-saravanak@google.com> <20230127001141.407071-10-saravanak@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230127001141.407071-10-saravanak@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230130_101550_642180_49C53634 X-CRM114-Status: GOOD ( 38.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Saravana, On Thu, Jan 26, 2023 at 04:11:36PM -0800, Saravana Kannan wrote: > The driver core now: > - Has the parent device of a supplier pick up the consumers if the > supplier never has a device created for it. > - Ignores a supplier if the supplier has no parent device and will never > be probed by a driver > > And already prevents creating a device link with the consumer as a > supplier of a parent. > > So, we no longer need to find the "compatible" node of the supplier or > do any other checks in of_link_to_phandle(). We simply need to make sure > that the supplier is available in DT. > > Signed-off-by: Saravana Kannan > --- > drivers/of/property.c | 84 +++++++------------------------------------ > 1 file changed, 13 insertions(+), 71 deletions(-) > > diff --git a/drivers/of/property.c b/drivers/of/property.c > index 134cfc980b70..c651aad6f34b 100644 > --- a/drivers/of/property.c > +++ b/drivers/of/property.c > @@ -1062,20 +1062,6 @@ of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, > return of_device_get_match_data(dev); > } > > -static bool of_is_ancestor_of(struct device_node *test_ancestor, > - struct device_node *child) > -{ > - of_node_get(child); > - while (child) { > - if (child == test_ancestor) { > - of_node_put(child); > - return true; > - } > - child = of_get_next_parent(child); > - } > - return false; > -} > - > static struct device_node *of_get_compat_node(struct device_node *np) > { > of_node_get(np); > @@ -1106,71 +1092,27 @@ static struct device_node *of_get_compat_node_parent(struct device_node *np) > return node; > } > > -/** > - * of_link_to_phandle - Add fwnode link to supplier from supplier phandle > - * @con_np: consumer device tree node > - * @sup_np: supplier device tree node > - * > - * Given a phandle to a supplier device tree node (@sup_np), this function > - * finds the device that owns the supplier device tree node and creates a > - * device link from @dev consumer device to the supplier device. This function > - * doesn't create device links for invalid scenarios such as trying to create a > - * link with a parent device as the consumer of its child device. In such > - * cases, it returns an error. > - * > - * Returns: > - * - 0 if fwnode link successfully created to supplier > - * - -EINVAL if the supplier link is invalid and should not be created > - * - -ENODEV if struct device will never be create for supplier > - */ > -static int of_link_to_phandle(struct device_node *con_np, > +static void of_link_to_phandle(struct device_node *con_np, > struct device_node *sup_np) > { > - struct device *sup_dev; > - struct device_node *tmp_np = sup_np; > + struct device_node *tmp_np = of_node_get(sup_np); > > - /* > - * Find the device node that contains the supplier phandle. It may be > - * @sup_np or it may be an ancestor of @sup_np. > - */ > - sup_np = of_get_compat_node(sup_np); > - if (!sup_np) { > - pr_debug("Not linking %pOFP to %pOFP - No device\n", > - con_np, tmp_np); > - return -ENODEV; > - } > + /* Check that sup_np and its ancestors are available. */ > + while (tmp_np) { > + if (of_fwnode_handle(tmp_np)->dev) { > + of_node_put(tmp_np); > + break; > + } > > - /* > - * Don't allow linking a device node as a consumer of one of its > - * descendant nodes. By definition, a child node can't be a functional > - * dependency for the parent node. > - */ > - if (of_is_ancestor_of(con_np, sup_np)) { > - pr_debug("Not linking %pOFP to %pOFP - is descendant\n", > - con_np, sup_np); > - of_node_put(sup_np); > - return -EINVAL; > - } > + if (!of_device_is_available(tmp_np)) { > + of_node_put(tmp_np); > + return; > + } > > - /* > - * Don't create links to "early devices" that won't have struct devices > - * created for them. > - */ > - sup_dev = get_dev_from_fwnode(&sup_np->fwnode); > - if (!sup_dev && > - (of_node_check_flag(sup_np, OF_POPULATED) || > - sup_np->fwnode.flags & FWNODE_FLAG_NOT_DEVICE)) { > - pr_debug("Not linking %pOFP to %pOFP - No struct device\n", > - con_np, sup_np); > - of_node_put(sup_np); > - return -ENODEV; > + tmp_np = of_get_next_parent(tmp_np); > } > - put_device(sup_dev); > > fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np)); fwnode_link_add() returns int. Why is the return type of this function changed to void? > - of_node_put(sup_np); > - > - return 0; > } > > /** -- Regards, Sakari Ailus _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel