]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
slimbus: qcom-ngd: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Fri, 16 Jan 2026 17:09:42 +0000 (17:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Jan 2026 14:53:49 +0000 (15:53 +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>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260116170942.733674-1-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/slimbus/qcom-ngd-ctrl.c

index ba3d80d12605cd3fe0a9f4b34b33de510e305f40..7338b38697d01597f754806a4d24c6b45a614cb5 100644 (file)
@@ -1514,26 +1514,22 @@ static int of_qcom_slim_ngd_register(struct device *parent,
        const struct ngd_reg_offset_data *data;
        struct qcom_slim_ngd *ngd;
        const struct of_device_id *match;
-       struct device_node *node;
        u32 id;
        int ret;
 
        match = of_match_node(qcom_slim_ngd_dt_match, parent->of_node);
        data = match->data;
-       for_each_available_child_of_node(parent->of_node, node) {
+       for_each_available_child_of_node_scoped(parent->of_node, node) {
                if (of_property_read_u32(node, "reg", &id))
                        continue;
 
                ngd = kzalloc(sizeof(*ngd), GFP_KERNEL);
-               if (!ngd) {
-                       of_node_put(node);
+               if (!ngd)
                        return -ENOMEM;
-               }
 
                ngd->pdev = platform_device_alloc(QCOM_SLIM_NGD_DRV_NAME, id);
                if (!ngd->pdev) {
                        kfree(ngd);
-                       of_node_put(node);
                        return -ENOMEM;
                }
                ngd->id = id;
@@ -1546,7 +1542,6 @@ static int of_qcom_slim_ngd_register(struct device *parent,
                if (ret) {
                        platform_device_put(ngd->pdev);
                        kfree(ngd);
-                       of_node_put(node);
                        return ret;
                }
                ngd->pdev->dev.of_node = node;
@@ -1556,7 +1551,6 @@ static int of_qcom_slim_ngd_register(struct device *parent,
                if (ret) {
                        platform_device_put(ngd->pdev);
                        kfree(ngd);
-                       of_node_put(node);
                        return ret;
                }
                ngd->base = ctrl->base + ngd->id * data->offset +