Skip to content

Commit 42f5b5e

Browse files
author
Desnes Nunes
committed
device property: Split fwnode_get_child_node_count()
JIRA: https://issues.redhat.com/browse/RHEL-116016 Conflicts: * This avoids commit bb39141 ("device property: Split property read- ing bool and presence test ops") that moves device_property_read_bool() out of property.h to property.c. These drivers base API changes are not necessary for USB, which only needs the new helper function added here commit 1490cbb Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: Mon, 10 Mar 2025 16:54:51 +0200 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> Signed-off-by: Desnes Nunes <desnesn@redhat.com>
1 parent cadbe5a commit 42f5b5e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

drivers/base/property.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -917,22 +917,22 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
917917
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
918918

919919
/**
920-
* device_get_child_node_count - return the number of child nodes for device
921-
* @dev: Device to count the child nodes for
920+
* fwnode_get_child_node_count - return the number of child nodes for a given firmware node
921+
* @fwnode: Pointer to the parent firmware node
922922
*
923-
* Return: the number of child nodes for a given device.
923+
* Return: the number of child nodes for a given firmware node.
924924
*/
925-
unsigned int device_get_child_node_count(const struct device *dev)
925+
unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode)
926926
{
927927
struct fwnode_handle *child;
928928
unsigned int count = 0;
929929

930-
device_for_each_child_node(dev, child)
930+
fwnode_for_each_child_node(fwnode, child)
931931
count++;
932932

933933
return count;
934934
}
935-
EXPORT_SYMBOL_GPL(device_get_child_node_count);
935+
EXPORT_SYMBOL_GPL(fwnode_get_child_node_count);
936936

937937
bool device_dma_supported(const struct device *dev)
938938
{

include/linux/property.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T))
179179
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
180180
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
181181

182-
unsigned int device_get_child_node_count(const struct device *dev);
182+
unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode);
183+
184+
static inline unsigned int device_get_child_node_count(const struct device *dev)
185+
{
186+
return fwnode_get_child_node_count(dev_fwnode(dev));
187+
}
183188

184189
static inline bool device_property_read_bool(const struct device *dev,
185190
const char *propname)

0 commit comments

Comments
 (0)