]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc: ti: knav: Simplify with scoped for each OF child loop
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Fri, 2 Jan 2026 12:47:33 +0000 (13:47 +0100)
committerNishanth Menon <nm@ti.com>
Mon, 5 Jan 2026 18:40:12 +0000 (12:40 -0600)
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/20260102124729.63964-9-krzysztof.kozlowski@oss.qualcomm.com
Signed-off-by: Nishanth Menon <nm@ti.com>
drivers/soc/ti/knav_qmss_queue.c

index ff097a1531a9219850f4153b2d4e764c9d4f5d65..86d7a9c9ae011afc02bbefc62afe0b7bfb4a1801 100644 (file)
@@ -1079,7 +1079,6 @@ static int knav_queue_setup_regions(struct knav_device *kdev,
        struct device_node *regions __free(device_node) =
                        of_get_child_by_name(node, "descriptor-regions");
        struct knav_region *region;
-       struct device_node *child;
        u32 temp[2];
        int ret;
 
@@ -1087,12 +1086,10 @@ static int knav_queue_setup_regions(struct knav_device *kdev,
                return dev_err_probe(dev, -ENODEV,
                                     "descriptor-regions not specified\n");
 
-       for_each_child_of_node(regions, child) {
+       for_each_child_of_node_scoped(regions, child) {
                region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL);
-               if (!region) {
-                       of_node_put(child);
+               if (!region)
                        return -ENOMEM;
-               }
 
                region->name = knav_queue_find_name(child);
                of_property_read_u32(child, "id", &region->id);
@@ -1396,7 +1393,6 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
        struct device_node *qmgrs __free(device_node) =
                        of_get_child_by_name(node, "qmgrs");
        struct knav_qmgr_info *qmgr;
-       struct device_node *child;
        u32 temp[2];
        int ret;
 
@@ -1404,12 +1400,10 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
                return dev_err_probe(dev, -ENODEV,
                                     "queue manager info not specified\n");
 
-       for_each_child_of_node(qmgrs, child) {
+       for_each_child_of_node_scoped(qmgrs, child) {
                qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL);
-               if (!qmgr) {
-                       of_node_put(child);
+               if (!qmgr)
                        return -ENOMEM;
-               }
 
                ret = of_property_read_u32_array(child, "managed-queues",
                                                 temp, 2);
@@ -1501,14 +1495,12 @@ static int knav_queue_init_pdsps(struct knav_device *kdev,
 {
        struct device *dev = kdev->dev;
        struct knav_pdsp_info *pdsp;
-       struct device_node *child;
 
-       for_each_child_of_node(pdsps, child) {
+       for_each_child_of_node_scoped(pdsps, child) {
                pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL);
-               if (!pdsp) {
-                       of_node_put(child);
+               if (!pdsp)
                        return -ENOMEM;
-               }
+
                pdsp->name = knav_queue_find_name(child);
                pdsp->iram =
                        knav_queue_map_reg(kdev, child,