[PATCH 2/7] mtd: rawnand: denali: Simplify with scoped for each OF child loop

Krzysztof Kozlowski
2026-01-02T12:49:50Z

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>
---
drivers/mtd/nand/raw/denali_dt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index e0dd59bba4bd..8c822eae72e7 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -115,7 +115,6 @@ static int denali_dt_probe(struct platform_device *pdev)
struct denali_dt *dt;
const struct denali_dt_data *data;
struct denali_controller *denali;
- struct device_node *np;
int ret;

dt = devm_kzalloc(dev, sizeof(*dt), GFP_KERNEL);
@@ -192,12 +191,10 @@ static int denali_dt_probe(struct platform_device *pdev)
if (ret)
goto out_assert_rst;

- for_each_child_of_node(dev->of_node, np) {
+ for_each_child_of_node_scoped(dev->of_node, np) {
ret = denali_dt_chip_init(denali, np);
- if (ret) {
- of_node_put(np);
+ if (ret)
goto out_remove_denali;
- }
}

platform_set_drvdata(pdev, dt);
--
2.51.0