]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mfd: core: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Wed, 24 Dec 2025 12:44:57 +0000 (13:44 +0100)
committerLee Jones <lee@kernel.org>
Thu, 22 Jan 2026 14:23:05 +0000 (14:23 +0000)
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251224124456.208529-3-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/mfd-core.c

index a30f93bf030aabfeb79abc9eedc00d8abf0ad129..68de2f74114226f987cd9a5392e9a1b6a32ead3a 100644 (file)
@@ -146,7 +146,6 @@ static int mfd_add_device(struct device *parent, int id,
 {
        struct resource *res;
        struct platform_device *pdev;
-       struct device_node *np = NULL;
        struct mfd_of_node_entry *of_entry, *tmp;
        bool disabled = false;
        int ret = -ENOMEM;
@@ -184,7 +183,7 @@ static int mfd_add_device(struct device *parent, int id,
                goto fail_res;
 
        if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) {
-               for_each_child_of_node(parent->of_node, np) {
+               for_each_child_of_node_scoped(parent->of_node, np) {
                        if (of_device_is_compatible(np, cell->of_compatible)) {
                                /* Skip 'disabled' devices */
                                if (!of_device_is_available(np)) {
@@ -195,7 +194,6 @@ static int mfd_add_device(struct device *parent, int id,
                                ret = mfd_match_of_node_to_dev(pdev, np, cell);
                                if (ret == -EAGAIN)
                                        continue;
-                               of_node_put(np);
                                if (ret)
                                        goto fail_alias;