Message ID | 20240826094328.2991664-9-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | f3b3c47ca41f696623e71596416d34fe1671d229 |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | mtd: Use for_each_child_of_node_scoped() | expand |
On Mon, Aug 26, 2024 at 11:37 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote: > Avoids the need for manual cleanup of_node_put() in early exits > from the loop. > > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert
On Mon, 2024-08-26 at 09:43:26 UTC, Jinjie Ruan wrote: > Avoids the need for manual cleanup of_node_put() in early exits > from the loop. > > Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks. Miquel
diff --git a/drivers/mtd/nand/raw/renesas-nand-controller.c b/drivers/mtd/nand/raw/renesas-nand-controller.c index c9a01feff8df..0e92d50c5249 100644 --- a/drivers/mtd/nand/raw/renesas-nand-controller.c +++ b/drivers/mtd/nand/raw/renesas-nand-controller.c @@ -1297,23 +1297,17 @@ static void rnandc_chips_cleanup(struct rnandc *rnandc) static int rnandc_chips_init(struct rnandc *rnandc) { - struct device_node *np; int ret; - for_each_child_of_node(rnandc->dev->of_node, np) { + for_each_child_of_node_scoped(rnandc->dev->of_node, np) { ret = rnandc_chip_init(rnandc, np); if (ret) { - of_node_put(np); - goto cleanup_chips; + rnandc_chips_cleanup(rnandc); + return ret; } } return 0; - -cleanup_chips: - rnandc_chips_cleanup(rnandc); - - return ret; } static int rnandc_probe(struct platform_device *pdev)
Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- drivers/mtd/nand/raw/renesas-nand-controller.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)