Skip to content

Commit 0d5c32b

Browse files
Jinjie Ruanmiquelraynal
authored andcommitted
mtd: rawnand: rockchip: Use for_each_child_of_node_scoped()
Avoids the need for manual cleanup of_node_put() in early exits from the loop. 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 707f2d0 commit 0d5c32b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ static void rk_nfc_chips_cleanup(struct rk_nfc *nfc)
12111211

12121212
static int rk_nfc_nand_chips_init(struct device *dev, struct rk_nfc *nfc)
12131213
{
1214-
struct device_node *np = dev->of_node, *nand_np;
1214+
struct device_node *np = dev->of_node;
12151215
int nchips = of_get_child_count(np);
12161216
int ret;
12171217

@@ -1221,10 +1221,9 @@ static int rk_nfc_nand_chips_init(struct device *dev, struct rk_nfc *nfc)
12211221
return -EINVAL;
12221222
}
12231223

1224-
for_each_child_of_node(np, nand_np) {
1224+
for_each_child_of_node_scoped(np, nand_np) {
12251225
ret = rk_nfc_nand_chip_init(dev, nfc, nand_np);
12261226
if (ret) {
1227-
of_node_put(nand_np);
12281227
rk_nfc_chips_cleanup(nfc);
12291228
return ret;
12301229
}

0 commit comments

Comments
 (0)