Skip to content

Commit 6b222f2

Browse files
krzknmenon
authored andcommitted
soc: ti: knav: Simplify with scoped for each OF child loop
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>
1 parent 9a97b21 commit 6b222f2

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

drivers/soc/ti/knav_qmss_queue.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,20 +1079,17 @@ static int knav_queue_setup_regions(struct knav_device *kdev,
10791079
struct device_node *regions __free(device_node) =
10801080
of_get_child_by_name(node, "descriptor-regions");
10811081
struct knav_region *region;
1082-
struct device_node *child;
10831082
u32 temp[2];
10841083
int ret;
10851084

10861085
if (!regions)
10871086
return dev_err_probe(dev, -ENODEV,
10881087
"descriptor-regions not specified\n");
10891088

1090-
for_each_child_of_node(regions, child) {
1089+
for_each_child_of_node_scoped(regions, child) {
10911090
region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL);
1092-
if (!region) {
1093-
of_node_put(child);
1091+
if (!region)
10941092
return -ENOMEM;
1095-
}
10961093

10971094
region->name = knav_queue_find_name(child);
10981095
of_property_read_u32(child, "id", &region->id);
@@ -1396,20 +1393,17 @@ static int knav_queue_init_qmgrs(struct knav_device *kdev,
13961393
struct device_node *qmgrs __free(device_node) =
13971394
of_get_child_by_name(node, "qmgrs");
13981395
struct knav_qmgr_info *qmgr;
1399-
struct device_node *child;
14001396
u32 temp[2];
14011397
int ret;
14021398

14031399
if (!qmgrs)
14041400
return dev_err_probe(dev, -ENODEV,
14051401
"queue manager info not specified\n");
14061402

1407-
for_each_child_of_node(qmgrs, child) {
1403+
for_each_child_of_node_scoped(qmgrs, child) {
14081404
qmgr = devm_kzalloc(dev, sizeof(*qmgr), GFP_KERNEL);
1409-
if (!qmgr) {
1410-
of_node_put(child);
1405+
if (!qmgr)
14111406
return -ENOMEM;
1412-
}
14131407

14141408
ret = of_property_read_u32_array(child, "managed-queues",
14151409
temp, 2);
@@ -1501,14 +1495,12 @@ static int knav_queue_init_pdsps(struct knav_device *kdev,
15011495
{
15021496
struct device *dev = kdev->dev;
15031497
struct knav_pdsp_info *pdsp;
1504-
struct device_node *child;
15051498

1506-
for_each_child_of_node(pdsps, child) {
1499+
for_each_child_of_node_scoped(pdsps, child) {
15071500
pdsp = devm_kzalloc(dev, sizeof(*pdsp), GFP_KERNEL);
1508-
if (!pdsp) {
1509-
of_node_put(child);
1501+
if (!pdsp)
15101502
return -ENOMEM;
1511-
}
1503+
15121504
pdsp->name = knav_queue_find_name(child);
15131505
pdsp->iram =
15141506
knav_queue_map_reg(kdev, child,

0 commit comments

Comments
 (0)