Skip to content

Commit fc214e5

Browse files
Jinjie Ruanmiquelraynal
authored andcommitted
mtd: rawnand: cadence: 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 7021a79 commit fc214e5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,7 +2836,6 @@ static void cadence_nand_chips_cleanup(struct cdns_nand_ctrl *cdns_ctrl)
28362836
static int cadence_nand_chips_init(struct cdns_nand_ctrl *cdns_ctrl)
28372837
{
28382838
struct device_node *np = cdns_ctrl->dev->of_node;
2839-
struct device_node *nand_np;
28402839
int max_cs = cdns_ctrl->caps2.max_banks;
28412840
int nchips, ret;
28422841

@@ -2849,10 +2848,9 @@ static int cadence_nand_chips_init(struct cdns_nand_ctrl *cdns_ctrl)
28492848
return -EINVAL;
28502849
}
28512850

2852-
for_each_child_of_node(np, nand_np) {
2851+
for_each_child_of_node_scoped(np, nand_np) {
28532852
ret = cadence_nand_chip_init(cdns_ctrl, nand_np);
28542853
if (ret) {
2855-
of_node_put(nand_np);
28562854
cadence_nand_chips_cleanup(cdns_ctrl);
28572855
return ret;
28582856
}

0 commit comments

Comments
 (0)