Commit 620097c6 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Rob Herring (Arm)
Browse files

of: Add for_each_compatible_node_scoped() helper



Just like looping through children and available children, add a scoped
helper for for_each_compatible_node() so error paths can drop
of_node_put() leading to simpler code.

Suggested-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260109-of-for-each-compatible-scoped-v3-1-c22fa2c0749a@oss.qualcomm.com


Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent c75afcb4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ ForEachMacros:
  - 'for_each_collection'
  - 'for_each_comp_order'
  - 'for_each_compatible_node'
  - 'for_each_compatible_node_scoped'
  - 'for_each_component_dais'
  - 'for_each_component_dais_safe'
  - 'for_each_conduit'
+7 −0
Original line number Diff line number Diff line
@@ -1485,6 +1485,13 @@ static inline int of_property_read_s32(const struct device_node *np,
#define for_each_compatible_node(dn, type, compatible) \
	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
	     dn = of_find_compatible_node(dn, type, compatible))

#define for_each_compatible_node_scoped(dn, type, compatible) \
	for (struct device_node *dn __free(device_node) =		\
	     of_find_compatible_node(NULL, type, compatible);		\
	     dn;							\
	     dn = of_find_compatible_node(dn, type, compatible))

#define for_each_matching_node(dn, matches) \
	for (dn = of_find_matching_node(NULL, matches); dn; \
	     dn = of_find_matching_node(dn, matches))
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ def parse_compatibles(file, compat_ignore_list):
		compat_list += parse_of_functions(data, "_is_compatible")
		compat_list += parse_of_functions(data, "of_find_compatible_node")
		compat_list += parse_of_functions(data, "for_each_compatible_node")
		compat_list += parse_of_functions(data, "for_each_compatible_node_scoped")
		compat_list += parse_of_functions(data, "of_get_compatible_child")

	return compat_list