Merge branch 'i2c/immutable/scoped_fwnode_child' into i2c/for-mergewindow

This commit is contained in:
Wolfram Sang 2025-09-25 22:42:24 +02:00
commit 54d6a978bb
2 changed files with 11 additions and 2 deletions

View File

@ -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;

View File

@ -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);