Skip to contentSkip to conversation

device property: Add scoped fwnode child node iterators

PATCH Applied Jean-François Lessard 5 participants 28 messages Sep 2, 2025 – Sep 25, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v4 cover device property: Add scoped fwnode child node iterators

This series adds scoped versions of fwnode iterator macros and converts existing manual implementation to use them.

The first patch adds the infrastructure macros following existing patterns for scoped iterators in the kernel. The second patch demonstrates fwnode_for_each_child_node_scoped() usage by converting existing manual __free() usage in i2c-core-slave.c.

This series introduces infrastructure for the TM16XX driver series, being the first user of fwnode_for_each_available_child_node_scoped(). See the related patch series:
auxdisplay: Add TM16xx 7-segment LED matrix display controllers driver

Changes in v4:
- drop the fwnode_for_each_named_child_node_scoped() variant (no user)
- add Reviewed-by tag to commit message of patch 2/2

Changes in v3:
- Split into separate patches as requested
- Infrastructure addition in patch 1/2
- Usage example in patch 2/2

Changes in v2:
- replace manual __free(fwnode_handle) of i2c-core-slave.c with fwnode_for_each_child_node_scoped

Jean-François Lessard (2):
device property: Add scoped fwnode child node iterators
i2c: core: Use fwnode_for_each_child_node_scoped()

 drivers/i2c/i2c-core-slave.c |  3 +--
 include/linux/property.h     | 10 ++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 1/2 device property: Add scoped fwnode child node iterators

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

---

Notes:
checkpatch reports false positives that are intentionally ignored:
MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE
This is a standard iterator pattern following kernel conventions.

 include/linux/property.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/property.h +10 -0
index 82f0cb3ab..862e20813 100644
@@ -176,6 +176,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
 	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
 	     child = fwnode_get_next_available_child_node(fwnode, child))
 
+#define fwnode_for_each_child_node_scoped(fwnode, child)		\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_child_node(fwnode, NULL);		\
+	     child; child = fwnode_get_next_child_node(fwnode, child))
+
+#define fwnode_for_each_available_child_node_scoped(fwnode, child)	\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_available_child_node(fwnode, NULL);	\
+	     child; child = fwnode_get_next_available_child_node(fwnode, child))
+
 struct fwnode_handle *device_get_next_child_node(const struct device *dev,
 						 struct fwnode_handle *child);
 
Signature · 1 line
2.43.0
maintainer Acked-by on v4 1/2
#2 lore raw
Quoted 11 lines · Jean-François Lessard

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

Quoted 6 lines

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

reviewer Reviewed-by on v4 1/2
#3 lore raw
In reply to Jean-François Lessard
Quoted 11 lines · Jean-François Lessard

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

Quoted 4 lines

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer
#4 lore raw
In reply to Jean-François Lessard

Hi Jean-François,

Quoted 35 lines · Jean-François Lessard

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

---

Notes:
checkpatch reports false positives that are intentionally ignored:
MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE
This is a standard iterator pattern following kernel conventions.

 include/linux/property.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/property.h +0 -0
index 82f0cb3ab..862e20813 100644
@@ -176,6 +176,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
 	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
 	     child = fwnode_get_next_available_child_node(fwnode, child))
 

include/linux/property.h struct fwnode_handle *fwnode_get_next_available_child_node( · line 188

Quoted 10 lines
include/linux/property.h +10 -0
+#define fwnode_for_each_child_node_scoped(fwnode, child)		\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_child_node(fwnode, NULL);		\
+	     child; child = fwnode_get_next_child_node(fwnode, child))
+
+#define fwnode_for_each_available_child_node_scoped(fwnode, child)	\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_available_child_node(fwnode, NULL);	\
+	     child; child = fwnode_get_next_available_child_node(fwnode, child))
+

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Quoted 3 lines
include/linux/property.h +0 -0
 struct fwnode_handle *device_get_next_child_node(const struct device *dev,
 						 struct fwnode_handle *child);
 
Signature · 3 lines
Kind regards,

Sakari Ailus
#5 lore raw

Hi Sakari,

Le 3 septembre 2025 09 h 18 min 32 s HAE, Sakari Ailus <[email protected]> a écrit :

Quoted 51 lines

Hi Jean-François,

Quoted 35 lines · Jean-François Lessard

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

---

Notes:
checkpatch reports false positives that are intentionally ignored:
MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE
This is a standard iterator pattern following kernel conventions.

 include/linux/property.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/property.h +0 -0
index 82f0cb3ab..862e20813 100644
@@ -176,6 +176,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
 	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
 	     child = fwnode_get_next_available_child_node(fwnode, child))
 

include/linux/property.h struct fwnode_handle *fwnode_get_next_available_child_node( · line 188

Quoted 10 lines
include/linux/property.h +10 -0
+#define fwnode_for_each_child_node_scoped(fwnode, child)		\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_child_node(fwnode, NULL);		\
+	     child; child = fwnode_get_next_child_node(fwnode, child))
+
+#define fwnode_for_each_available_child_node_scoped(fwnode, child)	\
+	for (struct fwnode_handle *child __free(fwnode_handle) =	\
+		fwnode_get_next_available_child_node(fwnode, NULL);	\
+	     child; child = fwnode_get_next_available_child_node(fwnode, child))
+

Do we really need the available variant?

Quoted 5 lines

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Thanks for the link to the discussion.

I see you're planning to remove fwnode_get_next_available_child_node() entirely. In that context, adding a scoped version doesn't make sense.

For my driver use case, I can handle the status checking manually if the _available_ variant is being deprecated.

Should I drop the _available_ variant and submit v5 with only fwnode_for_each_child_node_scoped()?

Quoted 4 lines
Quoted 3 lines
include/linux/property.h +0 -0
 struct fwnode_handle *device_get_next_child_node(const struct device *dev,
 						 struct fwnode_handle *child);
 
maintainer
#6 lore raw
In reply to Sakari Ailus

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

reviewer
#7 lore raw

Hi Danilo,

Quoted 14 lines · Danilo Krummrich

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Quoted 6 lines

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

On ACPI there's no such concept on ACPI data nodes so all data nodes are considered to be available. So effectively the fwnode_*available*() is always the same as the variant without _available().

Signature · 3 lines
Regards,

Sakari Ailus
maintainer
#8 lore raw
Quoted 20 lines · Sakari Ailus

Hi Danilo,

Quoted 17 lines · Danilo Krummrich

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

Quoted 7 lines
Quoted 3 lines

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

On ACPI there's no such concept on ACPI data nodes so all data nodes are considered to be available. So effectively the fwnode_*available*() is always the same as the variant without _available().

What about acpi_fwnode_device_is_available()? Is it guaranteed to always evaluate to true?

If so, to you plan to remove device_is_available() from struct fwnode_operations and fixup all users of fwnode_get_next_available_child_node() and fwnode_for_each_available_child_node() as well?

reviewer
#9 lore raw

Hi Danilo,

Quoted 25 lines · Danilo Krummrich
Quoted 24 lines · Sakari Ailus

Hi Danilo,

Quoted 20 lines · Danilo Krummrich

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

Quoted 6 lines
Quoted 3 lines

On ACPI there's no such concept on ACPI data nodes so all data nodes are considered to be available. So effectively the fwnode_*available*() is always the same as the variant without _available().

What about acpi_fwnode_device_is_available()? Is it guaranteed to always evaluate to true?

acpi_fwnode_device_is_available() is different as it works on ACPI device nodes having availability information.

Quoted 4 lines

If so, to you plan to remove device_is_available() from struct fwnode_operations and fixup all users of fwnode_get_next_available_child_node() and fwnode_for_each_available_child_node() as well?

The device_is_available() callback needs to stay; it has valid uses elsewhere.

Technically it is possible that fwnode_*child_node() functions could return device nodes that aren't available, but it is unlikely any caller would want to enumerate device nodes this way. Even so, I think it'd be the best to add an explicit availability check on ACPI side as well so only available nodes would be returned.

The fact that none of the drivers using the two available variants acting on child nodes had ACPI ID table suggests that the use of the variants was motivated solely to use a function named similarly to the OF version.

Signature · 3 lines
Kind regards,

Sakari Ailus
maintainer
#10 lore raw
Quoted 32 lines · Sakari Ailus

Hi Danilo,

Quoted 29 lines · Danilo Krummrich
Quoted 27 lines · Sakari Ailus

Hi Danilo,

Quoted 14 lines · Danilo Krummrich

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Quoted 6 lines

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

On ACPI there's no such concept on ACPI data nodes so all data nodes are considered to be available. So effectively the fwnode_*available*() is always the same as the variant without _available().

Quoted 5 lines
Quoted 2 lines

What about acpi_fwnode_device_is_available()? Is it guaranteed to always evaluate to true?

acpi_fwnode_device_is_available() is different as it works on ACPI device nodes having availability information.

Well, it works on both data and device nodes, so considering data nodes only isn't enough, no?

So, we can't just say fwnode_get_next_available_child_node() and fwnode_get_next_child_node() can be used interchangeably.

Quoted 4 lines
Quoted 3 lines

If so, to you plan to remove device_is_available() from struct fwnode_operations and fixup all users of fwnode_get_next_available_child_node() and fwnode_for_each_available_child_node() as well?

Quoted 8 lines

The device_is_available() callback needs to stay; it has valid uses elsewhere.

Technically it is possible that fwnode_*child_node() functions could return device nodes that aren't available, but it is unlikely any caller would want to enumerate device nodes this way. Even so, I think it'd be the best to add an explicit availability check on ACPI side as well so only available nodes would be returned.

Fair enough, but that's an entirely different rationale than the one you gave above. I.e. "all iterators should only ever provide available ones" vs. the "they're all available anyways" argument above.

(Quote: "So effectively the fwnode_*available*() is always the same as the
variant without _available().")

I see quite some drivers using fwnode_for_each_child_node() without any availability check. However, they may just rely on implementation details, such as knowing it's an OF node or ACPI data node, etc.

So, before you remove fwnode_get_next_available_child_node(), do you plan to change the semantics of the get_next_child_node() callback accordingly, including adding the availability check on the ACPI side?

How do we ensure there are no existing drivers relying on iterating also unavailble nodes? Above you say it's unlikely anyone actually wants this, but are we sure?

reviewer
#11 lore raw

Hi Danilo,

Quoted 58 lines · Danilo Krummrich
Quoted 32 lines · Sakari Ailus

Hi Danilo,

Quoted 29 lines · Danilo Krummrich
Quoted 27 lines · Sakari Ailus

Hi Danilo,

Quoted 14 lines · Danilo Krummrich

(Cc: Javier)

Quoted 6 lines · Sakari Ailus

Do we really need the available variant?

Please see <URL:https://lore.kernel.org/linux-acpi/[email protected]/>.

I'll post a patch to remove fwnode_get_next_available_child_node(), too.

Either I'm missing something substantial or the link does indeed not provide an obvious justification of why you want to send a patch to remove fwnode_get_next_available_child_node().

Quoted 6 lines

Do you mean to say that all fwnode backends always return true for device_is_available() and hence the fwnode API should not make this distinction?

I.e. are you referring to the fact that of_fwnode_get_next_child_node() always calls of_get_next_available_child() and swnode has no device_is_available() callback and hence is always available? What about ACPI?

On ACPI there's no such concept on ACPI data nodes so all data nodes are considered to be available. So effectively the fwnode_*available*() is always the same as the variant without _available().

Quoted 5 lines
Quoted 2 lines

What about acpi_fwnode_device_is_available()? Is it guaranteed to always evaluate to true?

acpi_fwnode_device_is_available() is different as it works on ACPI device nodes having availability information.

Well, it works on both data and device nodes, so considering data nodes only isn't enough, no?

So, we can't just say fwnode_get_next_available_child_node() and fwnode_get_next_child_node() can be used interchangeably.

Quoted 4 lines
Quoted 3 lines

If so, to you plan to remove device_is_available() from struct fwnode_operations and fixup all users of fwnode_get_next_available_child_node() and fwnode_for_each_available_child_node() as well?

Quoted 8 lines

The device_is_available() callback needs to stay; it has valid uses elsewhere.

Technically it is possible that fwnode_*child_node() functions could return device nodes that aren't available, but it is unlikely any caller would want to enumerate device nodes this way. Even so, I think it'd be the best to add an explicit availability check on ACPI side as well so only available nodes would be returned.

Quoted 6 lines

Fair enough, but that's an entirely different rationale than the one you gave above. I.e. "all iterators should only ever provide available ones" vs. the "they're all available anyways" argument above.

(Quote: "So effectively the fwnode_*available*() is always the same as the
variant without _available().")

This was perhaps a simplification. The word "effectively" is crucial here.

Quoted 5 lines

I see quite some drivers using fwnode_for_each_child_node() without any availability check. However, they may just rely on implementation details, such as knowing it's an OF node or ACPI data node, etc.

Quoted 7 lines

So, before you remove fwnode_get_next_available_child_node(), do you plan to change the semantics of the get_next_child_node() callback accordingly, including adding the availability check on the ACPI side?

How do we ensure there are no existing drivers relying on iterating also unavailble nodes? Above you say it's unlikely anyone actually wants this, but are we sure?

If you're concerned of the use on ACPI platforms, none of the drivers using the two available variants list any ACPI IDs, signifying they're not used on ACPI systems -- I don't think they ever have been.

I noticed there's also no availability check for the OF graph nodes. That's likely an accidental omission.

Signature · 3 lines
Kind regards,

Sakari Ailus
reviewer
#12 lore raw
Quoted 2 lines · Sakari Ailus

I noticed there's also no availability check for the OF graph nodes. That's likely an accidental omission.

After doing some further research, this seems to be correct. In OF, the status is defined for device nodes only. A child node could be a device whereas graph endpoints are not device nodes, so the lack of a check there is reasonable.

Signature · 1 line
Sakari Ailus
maintainer
#13 lore raw
In reply to Sakari Ailus
Quoted 3 lines · Sakari Ailus

If you're concerned of the use on ACPI platforms, none of the drivers using the two available variants list any ACPI IDs, signifying they're not used on ACPI systems -- I don't think they ever have been.

Great -- sounds reasonable then.

reviewer
#14 lore raw

Hi Danilo,

Quoted 6 lines · Danilo Krummrich
Quoted 3 lines · Sakari Ailus

If you're concerned of the use on ACPI platforms, none of the drivers using the two available variants list any ACPI IDs, signifying they're not used on ACPI systems -- I don't think they ever have been.

Great -- sounds reasonable then.

I opted to add availability check on the ACPI side as well so that DT and ACPI are aligned in not returning unavailable child devices.

Signature · 3 lines
Regards,

Sakari Ailus
Applied
#15 lore raw
In reply to Jean-François Lessard
Quoted 11 lines · Jean-François Lessard

Add scoped versions of fwnode child node iterators that automatically handle reference counting cleanup using the __free() attribute:

- fwnode_for_each_child_node_scoped()
- fwnode_for_each_available_child_node_scoped()

These macros follow the same pattern as existing scoped iterators in the kernel, ensuring fwnode references are automatically released when the iterator variable goes out of scope. This prevents resource leaks and eliminates the need for manual cleanup in error paths.

Quoted 6 lines

The implementation mirrors the non-scoped variants but uses __free(fwnode_handle) for automatic resource management, providing a safer and more convenient interface for drivers iterating over firmware node children.

Applied to for-next, thanks!

#16 lore raw

PATCH v4 2/2 i2c: core: Use fwnode_for_each_child_node_scoped()

In reply to Jean-François Lessard

Replace the manual __free(fwnode_handle) iterator declaration with the new scoped iterator macro for cleaner, less error-prone code.

This eliminates the need for explicit iterator variable declaration with the cleanup attribute, making the code more consistent with other scoped iterator usage patterns in the kernel.

---
 drivers/i2c/i2c-core-slave.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/i2c-core-slave.c +1 -2
index 7ee6b992b..02ca55c22 100644
@@ -112,10 +112,9 @@ bool i2c_detect_slave_mode(struct device *dev)
 	struct fwnode_handle *fwnode = dev_fwnode(dev);
 
 	if (is_of_node(fwnode)) {
-		struct fwnode_handle *child __free(fwnode_handle) = NULL;
 		u32 reg;
 
-		fwnode_for_each_child_node(fwnode, child) {
+		fwnode_for_each_child_node_scoped(fwnode, child) {
 			fwnode_property_read_u32(child, "reg", &reg);
 			if (reg & I2C_OWN_SLAVE_ADDRESS)
 				return true;
Signature · 1 line
2.43.0
reviewer Reviewed-by on v4 2/2
#17 lore raw

Re: [PATCH v4 2/2] i2c: core: Use fwnode_for_each_child_node_scoped()

Quoted 9 lines · Jean-François Lessard

Replace the manual __free(fwnode_handle) iterator declaration with the new scoped iterator macro for cleaner, less error-prone code.

This eliminates the need for explicit iterator variable declaration with the cleanup attribute, making the code more consistent with other scoped iterator usage patterns in the kernel.

Signature · 1 line
Sakari Ailus
Applied
#18 lore raw

Re: [PATCH v4 2/2] i2c: core: Use fwnode_for_each_child_node_scoped()

In reply to Jean-François Lessard
Quoted 9 lines · Jean-François Lessard

Replace the manual __free(fwnode_handle) iterator declaration with the new scoped iterator macro for cleaner, less error-prone code.

This eliminates the need for explicit iterator variable declaration with the cleanup attribute, making the code more consistent with other scoped iterator usage patterns in the kernel.

Applied to for-next, thanks!

#19 lore raw
In reply to Jean-François Lessard
Quoted 8 lines · Jean-François Lessard

This series adds scoped versions of fwnode iterator macros and converts existing manual implementation to use them.

The first patch adds the infrastructure macros following existing patterns for scoped iterators in the kernel. The second patch demonstrates fwnode_for_each_child_node_scoped() usage by converting existing manual __free() usage in i2c-core-slave.c.

Quoted 4 lines

This series introduces infrastructure for the TM16XX driver series, being the first user of fwnode_for_each_available_child_node_scoped(). See the related patch series:
auxdisplay: Add TM16xx 7-segment LED matrix display controllers driver

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#20 lore raw
Quoted 3 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

#21 lore raw
Quoted 6 lines · Wolfram Sang
Quoted 3 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup? I think we are not in hurry anyway, so let see if it settles down soon.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#22 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Wolfram Sang
Quoted 3 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup?

If Sakari attempts the rework, and we can prove this doesn't regress existing users, removing fwnode_for_each_available_child_node_scoped() in the context of the rework again should be trivial.

Given that, I don't see a reason to stall people working with the existing semantics of the API in the meantime.

So, AFAIC, my ACK is still valid.

reviewer Reviewed-by
#23 lore raw

Hi Danilo, others,

Quoted 6 lines · Danilo Krummrich
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Wolfram Sang
Quoted 3 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup?

If Sakari attempts the rework, and we can prove this doesn't regress existing users, removing fwnode_for_each_available_child_node_scoped() in the context of the rework again should be trivial.

It would perhaps be trivial but in this case I really wouldn't add it in the first place: it's unused. Either way, feel free to add:

Quoted 3 lines

Given that, I don't see a reason to stall people working with the existing semantics of the API in the meantime.

Signature · 3 lines
Regards,

Sakari Ailus
#24 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Wolfram Sang
Quoted 3 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup? I think we are not in hurry anyway, so let see if it settles down soon.

I pushed out an immutable branch now:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/immutable/scoped_fwnode_child

Please have a look if I got the tags correct. Once confirmed, I will merge it into i2c/for-mergewindow and Andy can pull it as well.

#25 lore raw

Andi,

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup? I think we are not in hurry anyway, so let see if it settles down soon.

Quoted 6 lines

I pushed out an immutable branch now:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/immutable/scoped_fwnode_child

Please have a look if I got the tags correct. Once confirmed, I will merge it into i2c/for-mergewindow and Andy can pull it as well.

Andy, did you pull this immutable branch already?

#26 lore raw
Quoted 9 lines · Wolfram Sang
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

It might be good to have an immutable branch for me from i2c core. Wolfram, can you provide a such if no objections?

Sure thing, I can do that. But there is still discussion on patch 1, so I will wait for an outcome there.

But it seems that the discussion can be implemented in a followup? I think we are not in hurry anyway, so let see if it settles down soon.

Quoted 8 lines
Quoted 6 lines

I pushed out an immutable branch now:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/immutable/scoped_fwnode_child

Please have a look if I got the tags correct. Once confirmed, I will merge it into i2c/for-mergewindow and Andy can pull it as well.

Andy, did you pull this immutable branch already?

Me? No, not yet.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#27 lore raw

Since there are no further comments, I pull this into my branch now? I was waiting for feedback, but I'll take it as 'no news, good news'