Skip to content

Commit 1490cbb

Browse files
andy-shevlag-linaro
authored andcommitted
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 <[email protected]> Acked-by: "Rafael J. Wysocki" <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 0af2f6b commit 1490cbb

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
@@ -928,22 +928,22 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
928928
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
929929

930930
/**
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
933933
*
934-
* Return: the number of child nodes for a given device.
934+
* Return: the number of child nodes for a given firmware node.
935935
*/
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)
937937
{
938938
struct fwnode_handle *child;
939939
unsigned int count = 0;
940940

941-
device_for_each_child_node(dev, child)
941+
fwnode_for_each_child_node(fwnode, child)
942942
count++;
943943

944944
return count;
945945
}
946-
EXPORT_SYMBOL_GPL(device_get_child_node_count);
946+
EXPORT_SYMBOL_GPL(fwnode_get_child_node_count);
947947

948948
bool device_dma_supported(const struct device *dev)
949949
{

include/linux/property.h

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

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+
}
212217

213218
static inline int device_property_read_u8(const struct device *dev,
214219
const char *propname, u8 *val)

0 commit comments

Comments
 (0)