Skip to content

Commit e2e4edd

Browse files
Jinjie Ruanmiquelraynal
authored andcommitted
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: Jinjie Ruan <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent fc214e5 commit e2e4edd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/mtd/nand/raw/pl35x-nand-controller.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ static void pl35x_nand_chips_cleanup(struct pl35x_nandc *nfc)
11111111

11121112
static int pl35x_nand_chips_init(struct pl35x_nandc *nfc)
11131113
{
1114-
struct device_node *np = nfc->dev->of_node, *nand_np;
1114+
struct device_node *np = nfc->dev->of_node;
11151115
int nchips = of_get_child_count(np);
11161116
int ret;
11171117

@@ -1121,10 +1121,9 @@ static int pl35x_nand_chips_init(struct pl35x_nandc *nfc)
11211121
return -EINVAL;
11221122
}
11231123

1124-
for_each_child_of_node(np, nand_np) {
1124+
for_each_child_of_node_scoped(np, nand_np) {
11251125
ret = pl35x_nand_chip_init(nfc, nand_np);
11261126
if (ret) {
1127-
of_node_put(nand_np);
11281127
pl35x_nand_chips_cleanup(nfc);
11291128
break;
11301129
}

0 commit comments

Comments
 (0)