Skip to content

Commit f5b30c7

Browse files
Jinjie Ruanmiquelraynal
authored andcommitted
mtd: rawnand: stm32_fmc2: 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 f3b3c47 commit f5b30c7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/mtd/nand/raw/stm32_fmc2_nand.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,6 @@ static int stm32_fmc2_nfc_parse_child(struct stm32_fmc2_nfc *nfc,
18511851
static int stm32_fmc2_nfc_parse_dt(struct stm32_fmc2_nfc *nfc)
18521852
{
18531853
struct device_node *dn = nfc->dev->of_node;
1854-
struct device_node *child;
18551854
int nchips = of_get_child_count(dn);
18561855
int ret = 0;
18571856

@@ -1865,12 +1864,10 @@ static int stm32_fmc2_nfc_parse_dt(struct stm32_fmc2_nfc *nfc)
18651864
return -EINVAL;
18661865
}
18671866

1868-
for_each_child_of_node(dn, child) {
1867+
for_each_child_of_node_scoped(dn, child) {
18691868
ret = stm32_fmc2_nfc_parse_child(nfc, child);
1870-
if (ret < 0) {
1871-
of_node_put(child);
1869+
if (ret < 0)
18721870
return ret;
1873-
}
18741871
}
18751872

18761873
return ret;

0 commit comments

Comments
 (0)