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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90950C433F5 for ; Tue, 16 Nov 2021 08:24:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5FEFD61B49 for ; Tue, 16 Nov 2021 08:24:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5FEFD61B49 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=CQRiY2LiOxIR+Zt6yn1YZe8bn5Jtl7w8brttNN/IyJo=; b=uvYPHHHTIMVzWk GMvcdZxVw6hVQkm2BV1S189gWdUe/oLQFFz4ku3VixJmACDtc+7OZ7DCzAHb45XGoPvcWewBWUyAj OOPK0sIq6Qn1p0V6NwF3SWpRulgnd4USpoVZsVsw9Jr0s+fU1/HIOBlExQBugsU6NFGANpcC5QePv SLS1VLMsCyIFNmmzA6GaDvMpKJO2x9OWpfpkVDzHHph/Ihj5zmy4ceyrJxG5PAK3oJwb4TLn6QElv Ci/0KGOK6olNR7rU2yujrVtmhmDnH3kvTWwFeWz4/oMZhmMs8g4Kg7PcLfo5shJ8OM73Zs70vxjaX U79etvIWqdqhX4b8ojhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtkb-000gbJ-RJ; Tue, 16 Nov 2021 08:23:34 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmtkX-000gZS-1K for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 08:23:30 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10169"; a="232369534" X-IronPort-AV: E=Sophos;i="5.87,238,1631602800"; d="scan'208";a="232369534" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2021 00:23:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,238,1631602800"; d="scan'208";a="645389141" Received: from kuha.fi.intel.com ([10.237.72.166]) by fmsmga001.fm.intel.com with SMTP; 16 Nov 2021 00:23:17 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 16 Nov 2021 10:23:16 +0200 Date: Tue, 16 Nov 2021 10:23:16 +0200 From: Heikki Krogerus To: Colin Foster Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Ioana Ciornei , Heiner Kallweit , Russell King , Lars Povlsen , Steen Hegelund , Linus Walleij , Philipp Zabel , Andy Shevchenko Subject: Re: [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count Message-ID: References: <20211116062328.1949151-1-colin.foster@in-advantage.com> <20211116062328.1949151-16-colin.foster@in-advantage.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211116062328.1949151-16-colin.foster@in-advantage.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_002329_145765_060596E7 X-CRM114-Status: GOOD ( 24.28 ) 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 On Mon, Nov 15, 2021 at 10:23:20PM -0800, Colin Foster wrote: > Functions existed for determining the node count by device, but not by > fwnode_handle. In the case where a driver could either be defined as a > standalone device or a node of a different device, parsing from the root of > the device might not make sense. As such, it becomes necessary to parse > from a child node instead of the device root node. > > Signed-off-by: Colin Foster > --- > drivers/base/property.c | 20 ++++++++++++++++---- > include/linux/property.h | 1 + > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index f1f35b48ab8b..2ee675e1529d 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -845,19 +845,31 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode) > EXPORT_SYMBOL_GPL(fwnode_device_is_available); > > /** > - * device_get_child_node_count - return the number of child nodes for device > - * @dev: Device to cound the child nodes for > + * fwnode_get_child_node_count - return the number of child nodes for the fwnode > + * @fwnode: Node to count the childe nodes for > */ > -unsigned int device_get_child_node_count(struct device *dev) > +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode) > { > struct fwnode_handle *child; > unsigned int count = 0; > > - device_for_each_child_node(dev, child) > + fwnode_for_each_child_node(fwnode, child) > count++; > > return count; > } > +EXPORT_SYMBOL_GPL(fwnode_get_child_node_count); > + > +/** > + * device_get_child_node_count - return the number of child nodes for device > + * @dev: Device to count the child nodes for > + */ > +unsigned int device_get_child_node_count(struct device *dev) > +{ > + struct fwnode_handle *fwnode = dev_fwnode(dev); > + > + return fwnode_get_child_node_count(fwnode); > +} > EXPORT_SYMBOL_GPL(device_get_child_node_count); > > bool device_dma_supported(struct device *dev) > diff --git a/include/linux/property.h b/include/linux/property.h > index 88fa726a76df..6dc71029cfc5 100644 > --- a/include/linux/property.h > +++ b/include/linux/property.h > @@ -122,6 +122,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode); > > int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); > > +unsigned int fwnode_get_child_node_count(struct fwnode_handle *fwnode); > unsigned int device_get_child_node_count(struct device *dev); You can now make device_get_child_node_count() an inline function: static inline unsigned int device_get_child_node_count(struct device *dev) { return fwnode_get_child_node_count(dev_fwnode(dev)); } thanks, -- heikki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel