[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211116062328.1949151-16-colin.foster@in-advantage.com>
Date: Mon, 15 Nov 2021 22:23:20 -0800
From: Colin Foster <colin.foster@...advantage.com>
To: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-gpio@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Vladimir Oltean <vladimir.oltean@....com>,
Claudiu Manoil <claudiu.manoil@....com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Ioana Ciornei <ioana.ciornei@....com>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Lars Povlsen <lars.povlsen@...rochip.com>,
Steen Hegelund <Steen.Hegelund@...rochip.com>,
Linus Walleij <linus.walleij@...aro.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [RFC PATCH v4 net-next 15/23] device property: add helper function fwnode_get_child_node_count
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 <colin.foster@...advantage.com>
---
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);
static inline bool device_property_read_bool(struct device *dev,
--
2.25.1
Powered by blists - more mailing lists