[PATCH 2/3] phy: core: Simplify with scoped for each OF child loop

From: Krzysztof Kozlowski
Date: Wed Dec 24 2025 - 07:47:23 EST


Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
---
drivers/phy/phy-core.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 8d227890a345..d57c9525fa38 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -138,17 +138,14 @@ static struct phy *phy_find(struct device *dev, const char *con_id)
static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
{
struct phy_provider *phy_provider;
- struct device_node *child;

list_for_each_entry(phy_provider, &phy_provider_list, list) {
if (phy_provider->dev->of_node == node)
return phy_provider;

- for_each_child_of_node(phy_provider->children, child)
- if (child == node) {
- of_node_put(child);
+ for_each_child_of_node_scoped(phy_provider->children, child)
+ if (child == node)
return phy_provider;
- }
}

return ERR_PTR(-EPROBE_DEFER);
--
2.51.0