Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memory: tegra-mc: simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-memory-v2-7-9eed0ee16b78@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

+3 -8
+3 -8
drivers/memory/tegra/mc.c
··· 450 450 451 451 static int load_timings(struct tegra_mc *mc, struct device_node *node) 452 452 { 453 - struct device_node *child; 454 453 struct tegra_mc_timing *timing; 455 454 int child_count = of_get_child_count(node); 456 455 int i = 0, err; ··· 461 462 462 463 mc->num_timings = child_count; 463 464 464 - for_each_child_of_node(node, child) { 465 + for_each_child_of_node_scoped(node, child) { 465 466 timing = &mc->timings[i++]; 466 467 467 468 err = load_one_timing(mc, timing, child); 468 - if (err) { 469 - of_node_put(child); 469 + if (err) 470 470 return err; 471 - } 472 471 } 473 472 474 473 return 0; ··· 474 477 475 478 static int tegra_mc_setup_timings(struct tegra_mc *mc) 476 479 { 477 - struct device_node *node; 478 480 u32 ram_code, node_ram_code; 479 481 int err; 480 482 ··· 481 485 482 486 mc->num_timings = 0; 483 487 484 - for_each_child_of_node(mc->dev->of_node, node) { 488 + for_each_child_of_node_scoped(mc->dev->of_node, node) { 485 489 err = of_property_read_u32(node, "nvidia,ram-code", 486 490 &node_ram_code); 487 491 if (err || (node_ram_code != ram_code)) 488 492 continue; 489 493 490 494 err = load_timings(mc, node); 491 - of_node_put(node); 492 495 if (err) 493 496 return err; 494 497 break;