]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bus: stm32_firewall: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Mon, 5 Jan 2026 14:36:59 +0000 (15:36 +0100)
committerAlexandre Torgue <alexandre.torgue@foss.st.com>
Wed, 25 Mar 2026 16:40:21 +0000 (17:40 +0100)
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>
Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260105143657.383621-5-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
drivers/bus/stm32_firewall.c

index bbcf42ad668aee8cb789dba0d4ab5c8050f21ad4..b023d1f4fcf7215f7f319b713295010752d20f3b 100644 (file)
@@ -240,7 +240,6 @@ EXPORT_SYMBOL_GPL(stm32_firewall_controller_unregister);
 int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller)
 {
        struct stm32_firewall *firewalls;
-       struct device_node *child;
        struct device *parent;
        unsigned int i;
        int len;
@@ -250,25 +249,20 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
 
        dev_dbg(parent, "Populating %s system bus\n", dev_name(firewall_controller->dev));
 
-       for_each_available_child_of_node(dev_of_node(parent), child) {
+       for_each_available_child_of_node_scoped(dev_of_node(parent), child) {
                /* The access-controllers property is mandatory for firewall bus devices */
                len = of_count_phandle_with_args(child, "access-controllers",
                                                 "#access-controller-cells");
-               if (len <= 0) {
-                       of_node_put(child);
+               if (len <= 0)
                        return -EINVAL;
-               }
 
                firewalls = kzalloc_objs(*firewalls, len);
-               if (!firewalls) {
-                       of_node_put(child);
+               if (!firewalls)
                        return -ENOMEM;
-               }
 
                err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
                if (err) {
                        kfree(firewalls);
-                       of_node_put(child);
                        return err;
                }