Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

device property: Split fwnode_get_child_node_count()

The new helper is introduced to allow counting the child firmware nodes
of their parent without requiring a device to be passed. This also makes
the fwnode and device property API more symmetrical with the rest.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20250310150835.3139322-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andy Shevchenko and committed by
Lee Jones
1490cbb9 0af2f6be

+12 -7
+6 -6
drivers/base/property.c
··· 928 928 EXPORT_SYMBOL_GPL(fwnode_device_is_available); 929 929 930 930 /** 931 - * device_get_child_node_count - return the number of child nodes for device 932 - * @dev: Device to count the child nodes for 931 + * fwnode_get_child_node_count - return the number of child nodes for a given firmware node 932 + * @fwnode: Pointer to the parent firmware node 933 933 * 934 - * Return: the number of child nodes for a given device. 934 + * Return: the number of child nodes for a given firmware node. 935 935 */ 936 - unsigned int device_get_child_node_count(const struct device *dev) 936 + unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode) 937 937 { 938 938 struct fwnode_handle *child; 939 939 unsigned int count = 0; 940 940 941 - device_for_each_child_node(dev, child) 941 + fwnode_for_each_child_node(fwnode, child) 942 942 count++; 943 943 944 944 return count; 945 945 } 946 - EXPORT_SYMBOL_GPL(device_get_child_node_count); 946 + EXPORT_SYMBOL_GPL(fwnode_get_child_node_count); 947 947 948 948 bool device_dma_supported(const struct device *dev) 949 949 {
+6 -1
include/linux/property.h
··· 208 208 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); 209 209 int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name); 210 210 211 - unsigned int device_get_child_node_count(const struct device *dev); 211 + unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode); 212 + 213 + static inline unsigned int device_get_child_node_count(const struct device *dev) 214 + { 215 + return fwnode_get_child_node_count(dev_fwnode(dev)); 216 + } 212 217 213 218 static inline int device_property_read_u8(const struct device *dev, 214 219 const char *propname, u8 *val)