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>
This commit is contained in:
parent
4c1a381a9e
commit
210059143b
@ -450,7 +450,6 @@ static int load_one_timing(struct tegra_mc *mc,
|
||||
|
||||
static int load_timings(struct tegra_mc *mc, struct device_node *node)
|
||||
{
|
||||
struct device_node *child;
|
||||
struct tegra_mc_timing *timing;
|
||||
int child_count = of_get_child_count(node);
|
||||
int i = 0, err;
|
||||
@ -462,14 +461,12 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node)
|
||||
|
||||
mc->num_timings = child_count;
|
||||
|
||||
for_each_child_of_node(node, child) {
|
||||
for_each_child_of_node_scoped(node, child) {
|
||||
timing = &mc->timings[i++];
|
||||
|
||||
err = load_one_timing(mc, timing, child);
|
||||
if (err) {
|
||||
of_node_put(child);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -477,7 +474,6 @@ static int load_timings(struct tegra_mc *mc, struct device_node *node)
|
||||
|
||||
static int tegra_mc_setup_timings(struct tegra_mc *mc)
|
||||
{
|
||||
struct device_node *node;
|
||||
u32 ram_code, node_ram_code;
|
||||
int err;
|
||||
|
||||
@ -485,14 +481,13 @@ static int tegra_mc_setup_timings(struct tegra_mc *mc)
|
||||
|
||||
mc->num_timings = 0;
|
||||
|
||||
for_each_child_of_node(mc->dev->of_node, node) {
|
||||
for_each_child_of_node_scoped(mc->dev->of_node, node) {
|
||||
err = of_property_read_u32(node, "nvidia,ram-code",
|
||||
&node_ram_code);
|
||||
if (err || (node_ram_code != ram_code))
|
||||
continue;
|
||||
|
||||
err = load_timings(mc, node);
|
||||
of_node_put(node);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user