summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFrank Li <Frank.Li@nxp.com>2026-06-25 10:17:21 -0400
committerSakari Ailus <sakari.ailus@linux.intel.com>2026-09-17 22:58:08 +0300
commit3b696f0d04fa42e58d2eacffd1365a56ac862db4 (patch)
tree393760cafd1ebf2580befc196eb48732aca4652e /include
parentb238116ccd4bb3dea52e306b7fca3d3f17995a98 (diff)
downloadlinux-next-3b696f0d04fa42e58d2eacffd1365a56ac862db4.tar.gz
linux-next-3b696f0d04fa42e58d2eacffd1365a56ac862db4.zip
device property: Introduce fwnode_graph_for_each_endpoint_scoped()
Similar to recently propose for_each_child_of_node_scoped() this new version of the loop macro instantiates a new local struct fwnode_handle * that uses the __free(fwnode_handle) auto cleanup handling so that if a reference to a node is held on early exit from the loop the reference will be released. If the loop runs to completion, the child pointer will be NULL and no action will be taken. The reason this is useful is that it removes the need for fwnode_handle_put() on early loop exits. If there is a need to retain the reference, then return_ptr(child) or no_free_ptr(child) may be used to safely disable the auto cleanup. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/linux/property.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/property.h b/include/linux/property.h
index 907c790a3f01..9143fe4f5c05 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -547,6 +547,11 @@ unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode,
for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child; \
child = fwnode_graph_get_next_endpoint(fwnode, child))
+#define fwnode_graph_for_each_endpoint_scoped(fwnode, child) \
+ for (struct fwnode_handle *child __free(fwnode_handle) = \
+ fwnode_graph_get_next_endpoint(fwnode, NULL); \
+ child; child = fwnode_graph_get_next_endpoint(fwnode, child))
+
int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint);