Commit e2e4eddf authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Miquel Raynal

mtd: rawnand: pl353: Use for_each_child_of_node_scoped()

Avoids the need for manual cleanup of_node_put() in early exits
from the loop by using for_each_child_of_node_scoped().
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240826094328.2991664-4-ruanjinjie@huawei.com
parent fc214e50
...@@ -1111,7 +1111,7 @@ static void pl35x_nand_chips_cleanup(struct pl35x_nandc *nfc) ...@@ -1111,7 +1111,7 @@ static void pl35x_nand_chips_cleanup(struct pl35x_nandc *nfc)
static int pl35x_nand_chips_init(struct pl35x_nandc *nfc) static int pl35x_nand_chips_init(struct pl35x_nandc *nfc)
{ {
struct device_node *np = nfc->dev->of_node, *nand_np; struct device_node *np = nfc->dev->of_node;
int nchips = of_get_child_count(np); int nchips = of_get_child_count(np);
int ret; int ret;
...@@ -1121,10 +1121,9 @@ static int pl35x_nand_chips_init(struct pl35x_nandc *nfc) ...@@ -1121,10 +1121,9 @@ static int pl35x_nand_chips_init(struct pl35x_nandc *nfc)
return -EINVAL; return -EINVAL;
} }
for_each_child_of_node(np, nand_np) { for_each_child_of_node_scoped(np, nand_np) {
ret = pl35x_nand_chip_init(nfc, nand_np); ret = pl35x_nand_chip_init(nfc, nand_np);
if (ret) { if (ret) {
of_node_put(nand_np);
pl35x_nand_chips_cleanup(nfc); pl35x_nand_chips_cleanup(nfc);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment