All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-01 12:55 ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Use scope based of_node_put() to simplify code. It reduces the chance
of forgetting of_node_put(), and also simplifies error handling path.
I not able to test the changes on all the hardwares, so driver owners,
please help review when you have time.

This patchset was inspired from Dan's comments on pinctrl-scmi-imx.c,
thanks.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (21):
      pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
      pinctrl: tegra: Use scope based of_node_put() cleanups
      pinctrl: sunplus: Use scope based of_node_put() cleanups
      pinctrl: stm32: Use scope based of_node_put() cleanups
      pinctrl: starfive: Use scope based of_node_put() cleanups
      pinctrl: sprd: Use scope based of_node_put() cleanups
      pinctrl: spear: Use scope based of_node_put() cleanups
      pinctrl: samsung: Use scope based of_node_put() cleanups
      pinctrl: renesas: Use scope based of_node_put() cleanups
      pinctrl: st: Use scope based of_node_put() cleanups
      pinctrl: rockchip: Use scope based of_node_put() cleanups
      pinctrl: k210: Use scope based of_node_put() cleanups
      pinctrl: equilibrium: Use scope based of_node_put() cleanups
      pinctrl: at91: Use scope based of_node_put() cleanups
      pinctrl: s32cc: Use scope based of_node_put() cleanups
      pinctrl: nomadik: Use scope based of_node_put() cleanups
      pinctrl: mediatek: Use scope based of_node_put() cleanups
      pinctrl: freescale: Use scope based of_node_put() cleanups
      pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
      pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
      pinctrl: pinconf-generic: Use scope based of_node_put() cleanups

 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c         |  6 ++--
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c              |  4 +--
 drivers/pinctrl/freescale/pinctrl-imx.c            | 31 +++++------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c      | 19 ++++------
 drivers/pinctrl/freescale/pinctrl-mxs.c            | 24 +++++--------
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c      |  4 +--
 drivers/pinctrl/mediatek/pinctrl-paris.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-abx500.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          |  4 +--
 drivers/pinctrl/nxp/pinctrl-s32cc.c                | 31 ++++++-----------
 drivers/pinctrl/pinconf-generic.c                  |  7 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  7 ++--
 drivers/pinctrl/pinctrl-at91.c                     | 17 +++------
 drivers/pinctrl/pinctrl-equilibrium.c              | 21 +++---------
 drivers/pinctrl/pinctrl-k210.c                     |  7 ++--
 drivers/pinctrl/pinctrl-rockchip.c                 | 14 +++-----
 drivers/pinctrl/pinctrl-st.c                       | 40 +++++++---------------
 drivers/pinctrl/renesas/pinctrl-rza1.c             | 14 +++-----
 drivers/pinctrl/renesas/pinctrl-rzg2l.c            | 10 ++----
 drivers/pinctrl/renesas/pinctrl-rzn1.c             | 23 ++++---------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c            |  7 ++--
 drivers/pinctrl/renesas/pinctrl.c                  |  7 ++--
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c       |  3 +-
 drivers/pinctrl/samsung/pinctrl-exynos.c           | 16 +++------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c          |  8 ++---
 drivers/pinctrl/samsung/pinctrl-samsung.c          | 26 ++++----------
 drivers/pinctrl/spear/pinctrl-spear.c              | 13 +++----
 drivers/pinctrl/sprd/pinctrl-sprd.c                | 14 +++-----
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 ++++++---------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++-----
 drivers/pinctrl/stm32/pinctrl-stm32.c              |  7 ++--
 drivers/pinctrl/sunplus/sppctl.c                   |  4 +--
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c         |  7 ++--
 drivers/pinctrl/tegra/pinctrl-tegra.c              | 10 ++----
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c            | 37 ++++++++------------
 35 files changed, 154 insertions(+), 341 deletions(-)
---
base-commit: bb7a2467e6beef44a80a17d45ebf2931e7631083
change-id: 20240429-pinctrl-cleanup-e4d461c32648

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 103+ messages in thread

* [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-01 12:55 ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Use scope based of_node_put() to simplify code. It reduces the chance
of forgetting of_node_put(), and also simplifies error handling path.
I not able to test the changes on all the hardwares, so driver owners,
please help review when you have time.

This patchset was inspired from Dan's comments on pinctrl-scmi-imx.c,
thanks.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (21):
      pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
      pinctrl: tegra: Use scope based of_node_put() cleanups
      pinctrl: sunplus: Use scope based of_node_put() cleanups
      pinctrl: stm32: Use scope based of_node_put() cleanups
      pinctrl: starfive: Use scope based of_node_put() cleanups
      pinctrl: sprd: Use scope based of_node_put() cleanups
      pinctrl: spear: Use scope based of_node_put() cleanups
      pinctrl: samsung: Use scope based of_node_put() cleanups
      pinctrl: renesas: Use scope based of_node_put() cleanups
      pinctrl: st: Use scope based of_node_put() cleanups
      pinctrl: rockchip: Use scope based of_node_put() cleanups
      pinctrl: k210: Use scope based of_node_put() cleanups
      pinctrl: equilibrium: Use scope based of_node_put() cleanups
      pinctrl: at91: Use scope based of_node_put() cleanups
      pinctrl: s32cc: Use scope based of_node_put() cleanups
      pinctrl: nomadik: Use scope based of_node_put() cleanups
      pinctrl: mediatek: Use scope based of_node_put() cleanups
      pinctrl: freescale: Use scope based of_node_put() cleanups
      pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
      pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
      pinctrl: pinconf-generic: Use scope based of_node_put() cleanups

 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c         |  6 ++--
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c              |  4 +--
 drivers/pinctrl/freescale/pinctrl-imx.c            | 31 +++++------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c      | 19 ++++------
 drivers/pinctrl/freescale/pinctrl-mxs.c            | 24 +++++--------
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c      |  4 +--
 drivers/pinctrl/mediatek/pinctrl-paris.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-abx500.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          |  4 +--
 drivers/pinctrl/nxp/pinctrl-s32cc.c                | 31 ++++++-----------
 drivers/pinctrl/pinconf-generic.c                  |  7 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  7 ++--
 drivers/pinctrl/pinctrl-at91.c                     | 17 +++------
 drivers/pinctrl/pinctrl-equilibrium.c              | 21 +++---------
 drivers/pinctrl/pinctrl-k210.c                     |  7 ++--
 drivers/pinctrl/pinctrl-rockchip.c                 | 14 +++-----
 drivers/pinctrl/pinctrl-st.c                       | 40 +++++++---------------
 drivers/pinctrl/renesas/pinctrl-rza1.c             | 14 +++-----
 drivers/pinctrl/renesas/pinctrl-rzg2l.c            | 10 ++----
 drivers/pinctrl/renesas/pinctrl-rzn1.c             | 23 ++++---------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c            |  7 ++--
 drivers/pinctrl/renesas/pinctrl.c                  |  7 ++--
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c       |  3 +-
 drivers/pinctrl/samsung/pinctrl-exynos.c           | 16 +++------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c          |  8 ++---
 drivers/pinctrl/samsung/pinctrl-samsung.c          | 26 ++++----------
 drivers/pinctrl/spear/pinctrl-spear.c              | 13 +++----
 drivers/pinctrl/sprd/pinctrl-sprd.c                | 14 +++-----
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 ++++++---------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++-----
 drivers/pinctrl/stm32/pinctrl-stm32.c              |  7 ++--
 drivers/pinctrl/sunplus/sppctl.c                   |  4 +--
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c         |  7 ++--
 drivers/pinctrl/tegra/pinctrl-tegra.c              | 10 ++----
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c            | 37 ++++++++------------
 35 files changed, 154 insertions(+), 341 deletions(-)
---
base-commit: bb7a2467e6beef44a80a17d45ebf2931e7631083
change-id: 20240429-pinctrl-cleanup-e4d461c32648

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-01 12:55 ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Use scope based of_node_put() to simplify code. It reduces the chance
of forgetting of_node_put(), and also simplifies error handling path.
I not able to test the changes on all the hardwares, so driver owners,
please help review when you have time.

This patchset was inspired from Dan's comments on pinctrl-scmi-imx.c,
thanks.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (21):
      pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
      pinctrl: tegra: Use scope based of_node_put() cleanups
      pinctrl: sunplus: Use scope based of_node_put() cleanups
      pinctrl: stm32: Use scope based of_node_put() cleanups
      pinctrl: starfive: Use scope based of_node_put() cleanups
      pinctrl: sprd: Use scope based of_node_put() cleanups
      pinctrl: spear: Use scope based of_node_put() cleanups
      pinctrl: samsung: Use scope based of_node_put() cleanups
      pinctrl: renesas: Use scope based of_node_put() cleanups
      pinctrl: st: Use scope based of_node_put() cleanups
      pinctrl: rockchip: Use scope based of_node_put() cleanups
      pinctrl: k210: Use scope based of_node_put() cleanups
      pinctrl: equilibrium: Use scope based of_node_put() cleanups
      pinctrl: at91: Use scope based of_node_put() cleanups
      pinctrl: s32cc: Use scope based of_node_put() cleanups
      pinctrl: nomadik: Use scope based of_node_put() cleanups
      pinctrl: mediatek: Use scope based of_node_put() cleanups
      pinctrl: freescale: Use scope based of_node_put() cleanups
      pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
      pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
      pinctrl: pinconf-generic: Use scope based of_node_put() cleanups

 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c         |  6 ++--
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c              |  4 +--
 drivers/pinctrl/freescale/pinctrl-imx.c            | 31 +++++------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c      | 19 ++++------
 drivers/pinctrl/freescale/pinctrl-mxs.c            | 24 +++++--------
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c      |  4 +--
 drivers/pinctrl/mediatek/pinctrl-paris.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-abx500.c           |  4 +--
 drivers/pinctrl/nomadik/pinctrl-nomadik.c          |  4 +--
 drivers/pinctrl/nxp/pinctrl-s32cc.c                | 31 ++++++-----------
 drivers/pinctrl/pinconf-generic.c                  |  7 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c                |  7 ++--
 drivers/pinctrl/pinctrl-at91.c                     | 17 +++------
 drivers/pinctrl/pinctrl-equilibrium.c              | 21 +++---------
 drivers/pinctrl/pinctrl-k210.c                     |  7 ++--
 drivers/pinctrl/pinctrl-rockchip.c                 | 14 +++-----
 drivers/pinctrl/pinctrl-st.c                       | 40 +++++++---------------
 drivers/pinctrl/renesas/pinctrl-rza1.c             | 14 +++-----
 drivers/pinctrl/renesas/pinctrl-rzg2l.c            | 10 ++----
 drivers/pinctrl/renesas/pinctrl-rzn1.c             | 23 ++++---------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c            |  7 ++--
 drivers/pinctrl/renesas/pinctrl.c                  |  7 ++--
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c       |  3 +-
 drivers/pinctrl/samsung/pinctrl-exynos.c           | 16 +++------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c          |  8 ++---
 drivers/pinctrl/samsung/pinctrl-samsung.c          | 26 ++++----------
 drivers/pinctrl/spear/pinctrl-spear.c              | 13 +++----
 drivers/pinctrl/sprd/pinctrl-sprd.c                | 14 +++-----
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 ++++++---------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++-----
 drivers/pinctrl/stm32/pinctrl-stm32.c              |  7 ++--
 drivers/pinctrl/sunplus/sppctl.c                   |  4 +--
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c         |  7 ++--
 drivers/pinctrl/tegra/pinctrl-tegra.c              | 10 ++----
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c            | 37 ++++++++------------
 35 files changed, 154 insertions(+), 341 deletions(-)
---
base-commit: bb7a2467e6beef44a80a17d45ebf2931e7631083
change-id: 20240429-pinctrl-cleanup-e4d461c32648

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:55   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 37 +++++++++++++--------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..1032bc9c36aa 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match);
 static int ti_iodelay_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = of_node_get(dev->of_node);
+	struct device_node *np __free(device_node) = of_node_get(dev->of_node);
 	struct resource *res;
 	struct ti_iodelay_device *iod;
-	int ret = 0;
+	int ret;
 
 	if (!np) {
-		ret = -EINVAL;
 		dev_err(dev, "No OF node\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
-	if (!iod) {
-		ret = -ENOMEM;
-		goto exit_out;
-	}
+	if (!iod)
+		return -ENOMEM;
+
 	iod->dev = dev;
 	iod->reg_data = device_get_match_data(dev);
 	if (!iod->reg_data) {
-		ret = -EINVAL;
 		dev_err(dev, "No DATA match\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	/* So far We can assume there is only 1 bank of registers */
 	iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(iod->reg_base)) {
-		ret = PTR_ERR(iod->reg_base);
-		goto exit_out;
-	}
+	if (IS_ERR(iod->reg_base))
+		return PTR_ERR(iod->reg_base);
+
 	iod->phys_base = res->start;
 
 	iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
 					    iod->reg_data->regmap_config);
 	if (IS_ERR(iod->regmap)) {
 		dev_err(dev, "Regmap MMIO init failed.\n");
-		ret = PTR_ERR(iod->regmap);
-		goto exit_out;
+		return PTR_ERR(iod->regmap);
 	}
 
 	ret = ti_iodelay_pinconf_init_dev(iod);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	ret = ti_iodelay_alloc_pins(dev, iod, res->start);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
 	/* no pinmux ops - we are pinconf */
@@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
 	if (ret) {
 		dev_err(dev, "Failed to register pinctrl\n");
-		goto exit_out;
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, iod);
 
 	return pinctrl_enable(iod->pctl);
-
-exit_out:
-	of_node_put(np);
-	return ret;
 }
 
 /**

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-01 12:55   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 37 +++++++++++++--------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..1032bc9c36aa 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match);
 static int ti_iodelay_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = of_node_get(dev->of_node);
+	struct device_node *np __free(device_node) = of_node_get(dev->of_node);
 	struct resource *res;
 	struct ti_iodelay_device *iod;
-	int ret = 0;
+	int ret;
 
 	if (!np) {
-		ret = -EINVAL;
 		dev_err(dev, "No OF node\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
-	if (!iod) {
-		ret = -ENOMEM;
-		goto exit_out;
-	}
+	if (!iod)
+		return -ENOMEM;
+
 	iod->dev = dev;
 	iod->reg_data = device_get_match_data(dev);
 	if (!iod->reg_data) {
-		ret = -EINVAL;
 		dev_err(dev, "No DATA match\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	/* So far We can assume there is only 1 bank of registers */
 	iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(iod->reg_base)) {
-		ret = PTR_ERR(iod->reg_base);
-		goto exit_out;
-	}
+	if (IS_ERR(iod->reg_base))
+		return PTR_ERR(iod->reg_base);
+
 	iod->phys_base = res->start;
 
 	iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
 					    iod->reg_data->regmap_config);
 	if (IS_ERR(iod->regmap)) {
 		dev_err(dev, "Regmap MMIO init failed.\n");
-		ret = PTR_ERR(iod->regmap);
-		goto exit_out;
+		return PTR_ERR(iod->regmap);
 	}
 
 	ret = ti_iodelay_pinconf_init_dev(iod);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	ret = ti_iodelay_alloc_pins(dev, iod, res->start);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
 	/* no pinmux ops - we are pinconf */
@@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
 	if (ret) {
 		dev_err(dev, "Failed to register pinctrl\n");
-		goto exit_out;
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, iod);
 
 	return pinctrl_enable(iod->pctl);
-
-exit_out:
-	of_node_put(np);
-	return ret;
 }
 
 /**

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-01 12:55   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:55 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 37 +++++++++++++--------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..1032bc9c36aa 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match);
 static int ti_iodelay_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = of_node_get(dev->of_node);
+	struct device_node *np __free(device_node) = of_node_get(dev->of_node);
 	struct resource *res;
 	struct ti_iodelay_device *iod;
-	int ret = 0;
+	int ret;
 
 	if (!np) {
-		ret = -EINVAL;
 		dev_err(dev, "No OF node\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
-	if (!iod) {
-		ret = -ENOMEM;
-		goto exit_out;
-	}
+	if (!iod)
+		return -ENOMEM;
+
 	iod->dev = dev;
 	iod->reg_data = device_get_match_data(dev);
 	if (!iod->reg_data) {
-		ret = -EINVAL;
 		dev_err(dev, "No DATA match\n");
-		goto exit_out;
+		return -EINVAL;
 	}
 
 	/* So far We can assume there is only 1 bank of registers */
 	iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(iod->reg_base)) {
-		ret = PTR_ERR(iod->reg_base);
-		goto exit_out;
-	}
+	if (IS_ERR(iod->reg_base))
+		return PTR_ERR(iod->reg_base);
+
 	iod->phys_base = res->start;
 
 	iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
 					    iod->reg_data->regmap_config);
 	if (IS_ERR(iod->regmap)) {
 		dev_err(dev, "Regmap MMIO init failed.\n");
-		ret = PTR_ERR(iod->regmap);
-		goto exit_out;
+		return PTR_ERR(iod->regmap);
 	}
 
 	ret = ti_iodelay_pinconf_init_dev(iod);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	ret = ti_iodelay_alloc_pins(dev, iod, res->start);
 	if (ret)
-		goto exit_out;
+		return ret;
 
 	iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
 	/* no pinmux ops - we are pinconf */
@@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
 	if (ret) {
 		dev_err(dev, "Failed to register pinctrl\n");
-		goto exit_out;
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, iod);
 
 	return pinctrl_enable(iod->pctl);
-
-exit_out:
-	of_node_put(np);
-	return ret;
 }
 
 /**

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 02/21] pinctrl: tegra: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c |  7 ++-----
 drivers/pinctrl/tegra/pinctrl-tegra.c      | 10 +++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
index 96ef57a7d385..49c5edeba87f 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
@@ -238,20 +238,17 @@ static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl,
 {
 	struct tegra_xusb_padctl *padctl = pinctrl_dev_get_drvdata(pinctrl);
 	unsigned int reserved_maps = 0;
-	struct device_node *np;
 	int err;
 
 	*num_maps = 0;
 	*maps = NULL;
 
-	for_each_child_of_node(parent, np) {
+	for_each_child_of_node_scoped(parent, np) {
 		err = tegra_xusb_padctl_parse_subnode(padctl, np, maps,
 						      &reserved_maps,
 						      num_maps);
-		if (err < 0) {
-			of_node_put(np);
+		if (err < 0)
 			return err;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index ccfa3870a67d..69088609a0c8 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -188,20 +188,18 @@ static int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = tegra_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						      &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map,
 				*num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -759,17 +757,15 @@ DEFINE_NOIRQ_DEV_PM_OPS(tegra_pinctrl_pm, tegra_pinctrl_suspend, tegra_pinctrl_r
 
 static bool tegra_pinctrl_gpio_node_has_range(struct tegra_pmx *pmx)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) =
+		of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	bool has_prop = false;
 
-	np = of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	if (!np)
 		return has_prop;
 
 	has_prop = of_find_property(np, "gpio-ranges", NULL);
 
-	of_node_put(np);
-
 	return has_prop;
 }
 

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 02/21] pinctrl: tegra: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c |  7 ++-----
 drivers/pinctrl/tegra/pinctrl-tegra.c      | 10 +++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
index 96ef57a7d385..49c5edeba87f 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
@@ -238,20 +238,17 @@ static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl,
 {
 	struct tegra_xusb_padctl *padctl = pinctrl_dev_get_drvdata(pinctrl);
 	unsigned int reserved_maps = 0;
-	struct device_node *np;
 	int err;
 
 	*num_maps = 0;
 	*maps = NULL;
 
-	for_each_child_of_node(parent, np) {
+	for_each_child_of_node_scoped(parent, np) {
 		err = tegra_xusb_padctl_parse_subnode(padctl, np, maps,
 						      &reserved_maps,
 						      num_maps);
-		if (err < 0) {
-			of_node_put(np);
+		if (err < 0)
 			return err;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index ccfa3870a67d..69088609a0c8 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -188,20 +188,18 @@ static int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = tegra_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						      &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map,
 				*num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -759,17 +757,15 @@ DEFINE_NOIRQ_DEV_PM_OPS(tegra_pinctrl_pm, tegra_pinctrl_suspend, tegra_pinctrl_r
 
 static bool tegra_pinctrl_gpio_node_has_range(struct tegra_pmx *pmx)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) =
+		of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	bool has_prop = false;
 
-	np = of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	if (!np)
 		return has_prop;
 
 	has_prop = of_find_property(np, "gpio-ranges", NULL);
 
-	of_node_put(np);
-
 	return has_prop;
 }
 

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 02/21] pinctrl: tegra: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c |  7 ++-----
 drivers/pinctrl/tegra/pinctrl-tegra.c      | 10 +++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
index 96ef57a7d385..49c5edeba87f 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
@@ -238,20 +238,17 @@ static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl,
 {
 	struct tegra_xusb_padctl *padctl = pinctrl_dev_get_drvdata(pinctrl);
 	unsigned int reserved_maps = 0;
-	struct device_node *np;
 	int err;
 
 	*num_maps = 0;
 	*maps = NULL;
 
-	for_each_child_of_node(parent, np) {
+	for_each_child_of_node_scoped(parent, np) {
 		err = tegra_xusb_padctl_parse_subnode(padctl, np, maps,
 						      &reserved_maps,
 						      num_maps);
-		if (err < 0) {
-			of_node_put(np);
+		if (err < 0)
 			return err;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index ccfa3870a67d..69088609a0c8 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -188,20 +188,18 @@ static int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = tegra_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						      &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map,
 				*num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -759,17 +757,15 @@ DEFINE_NOIRQ_DEV_PM_OPS(tegra_pinctrl_pm, tegra_pinctrl_suspend, tegra_pinctrl_r
 
 static bool tegra_pinctrl_gpio_node_has_range(struct tegra_pmx *pmx)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) =
+		of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	bool has_prop = false;
 
-	np = of_find_compatible_node(NULL, NULL, pmx->soc->gpio_compatible);
 	if (!np)
 		return has_prop;
 
 	has_prop = of_find_property(np, "gpio-ranges", NULL);
 
-	of_node_put(np);
-
 	return has_prop;
 }
 

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 03/21] pinctrl: sunplus: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sunplus/sppctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index ae156f779a16..604256ec9079 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -823,7 +823,7 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 	int nmG = of_property_count_strings(np_config, "groups");
 	const struct sppctl_func *f = NULL;
 	u8 pin_num, pin_type, pin_func;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	unsigned long *configs;
 	struct property *prop;
 	const char *s_f, *s_g;
@@ -964,7 +964,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		}
 	}
 
-	of_node_put(parent);
 	dev_dbg(pctldev->dev, "%d pins mapped\n", *num_maps);
 	return 0;
 
@@ -973,7 +972,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
 			kfree((*map)[i].data.configs.configs);
 	kfree(*map);
-	of_node_put(parent);
 	return -ENOMEM;
 }
 

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 03/21] pinctrl: sunplus: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sunplus/sppctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index ae156f779a16..604256ec9079 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -823,7 +823,7 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 	int nmG = of_property_count_strings(np_config, "groups");
 	const struct sppctl_func *f = NULL;
 	u8 pin_num, pin_type, pin_func;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	unsigned long *configs;
 	struct property *prop;
 	const char *s_f, *s_g;
@@ -964,7 +964,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		}
 	}
 
-	of_node_put(parent);
 	dev_dbg(pctldev->dev, "%d pins mapped\n", *num_maps);
 	return 0;
 
@@ -973,7 +972,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
 			kfree((*map)[i].data.configs.configs);
 	kfree(*map);
-	of_node_put(parent);
 	return -ENOMEM;
 }
 

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 03/21] pinctrl: sunplus: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sunplus/sppctl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/sppctl.c
index ae156f779a16..604256ec9079 100644
--- a/drivers/pinctrl/sunplus/sppctl.c
+++ b/drivers/pinctrl/sunplus/sppctl.c
@@ -823,7 +823,7 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 	int nmG = of_property_count_strings(np_config, "groups");
 	const struct sppctl_func *f = NULL;
 	u8 pin_num, pin_type, pin_func;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	unsigned long *configs;
 	struct property *prop;
 	const char *s_f, *s_g;
@@ -964,7 +964,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		}
 	}
 
-	of_node_put(parent);
 	dev_dbg(pctldev->dev, "%d pins mapped\n", *num_maps);
 	return 0;
 
@@ -973,7 +972,6 @@ static int sppctl_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node
 		if ((*map)[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
 			kfree((*map)[i].data.configs.configs);
 	kfree(*map);
-	of_node_put(parent);
 	return -ENOMEM;
 }
 

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 04/21] pinctrl: stm32: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 978ccdbaf3d3..ca163a91e724 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -670,7 +670,6 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -678,12 +677,11 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = stm32_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -1401,7 +1399,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
 static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct irq_domain *domain;
 
 	if (!of_property_present(np, "interrupt-parent"))
@@ -1412,7 +1410,6 @@ static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pde
 		return ERR_PTR(-ENXIO);
 
 	domain = irq_find_host(parent);
-	of_node_put(parent);
 	if (!domain)
 		/* domain not registered yet */
 		return ERR_PTR(-EPROBE_DEFER);

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 04/21] pinctrl: stm32: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 978ccdbaf3d3..ca163a91e724 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -670,7 +670,6 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -678,12 +677,11 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = stm32_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -1401,7 +1399,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
 static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct irq_domain *domain;
 
 	if (!of_property_present(np, "interrupt-parent"))
@@ -1412,7 +1410,6 @@ static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pde
 		return ERR_PTR(-ENXIO);
 
 	domain = irq_find_host(parent);
-	of_node_put(parent);
 	if (!domain)
 		/* domain not registered yet */
 		return ERR_PTR(-EPROBE_DEFER);

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 04/21] pinctrl: stm32: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 978ccdbaf3d3..ca163a91e724 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -670,7 +670,6 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -678,12 +677,11 @@ static int stm32_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = stm32_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -1401,7 +1399,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode
 static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct irq_domain *domain;
 
 	if (!of_property_present(np, "interrupt-parent"))
@@ -1412,7 +1410,6 @@ static struct irq_domain *stm32_pctrl_get_irq_domain(struct platform_device *pde
 		return ERR_PTR(-ENXIO);
 
 	domain = irq_find_host(parent);
-	of_node_put(parent);
 	if (!domain)
 		/* domain not registered yet */
 		return ERR_PTR(-EPROBE_DEFER);

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
 2 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
index 6df7a310c7ed..27f99183d994 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
@@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = sfp->gc.parent;
-	struct device_node *child;
 	struct pinctrl_map *map;
 	const char **pgnames;
 	const char *grpname;
@@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	nmaps = 0;
 	ngroups = 0;
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npinmux = of_property_count_u32_elems(child, "pinmux");
 		int npins   = of_property_count_u32_elems(child, "pins");
 
 		if (npinmux > 0 && npins > 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 		if (npinmux == 0 && npins == 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins;
 		int i;
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 			if (!pinmux) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 			if (ret)
-				goto put_child;
+				goto free_map;
 
 			for (i = 0; i < npins; i++) {
 				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
@@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = NULL;
@@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 				ret = of_property_read_u32_index(child, "pins", i, &v);
 				if (ret)
-					goto put_child;
+					goto free_map;
 				pins[i] = v;
 			}
 		} else {
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	mutex_unlock(&sfp->mutex);
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);
diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
index 9609eb1ecc3d..4ce080caa233 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
@@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins = of_property_count_u32_elems(child, "pinmux");
 		int *pins;
 		u32 *pinmux;
@@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
 				np, child);
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 		if (!pins) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 		if (!pinmux) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 		if (ret)
-			goto put_child;
+			goto free_map;
 
 		for (i = 0; i < npins; i++)
 			pins[i] = jh7110_pinmux_pin(pinmux[i]);
@@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 						pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = nmaps;
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
 2 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
index 6df7a310c7ed..27f99183d994 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
@@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = sfp->gc.parent;
-	struct device_node *child;
 	struct pinctrl_map *map;
 	const char **pgnames;
 	const char *grpname;
@@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	nmaps = 0;
 	ngroups = 0;
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npinmux = of_property_count_u32_elems(child, "pinmux");
 		int npins   = of_property_count_u32_elems(child, "pins");
 
 		if (npinmux > 0 && npins > 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 		if (npinmux == 0 && npins == 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins;
 		int i;
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 			if (!pinmux) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 			if (ret)
-				goto put_child;
+				goto free_map;
 
 			for (i = 0; i < npins; i++) {
 				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
@@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = NULL;
@@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 				ret = of_property_read_u32_index(child, "pins", i, &v);
 				if (ret)
-					goto put_child;
+					goto free_map;
 				pins[i] = v;
 			}
 		} else {
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	mutex_unlock(&sfp->mutex);
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);
diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
index 9609eb1ecc3d..4ce080caa233 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
@@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins = of_property_count_u32_elems(child, "pinmux");
 		int *pins;
 		u32 *pinmux;
@@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
 				np, child);
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 		if (!pins) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 		if (!pinmux) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 		if (ret)
-			goto put_child;
+			goto free_map;
 
 		for (i = 0; i < npins; i++)
 			pins[i] = jh7110_pinmux_pin(pinmux[i]);
@@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 						pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = nmaps;
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
 drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
 2 files changed, 19 insertions(+), 26 deletions(-)

diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
index 6df7a310c7ed..27f99183d994 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
@@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = sfp->gc.parent;
-	struct device_node *child;
 	struct pinctrl_map *map;
 	const char **pgnames;
 	const char *grpname;
@@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	nmaps = 0;
 	ngroups = 0;
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npinmux = of_property_count_u32_elems(child, "pinmux");
 		int npins   = of_property_count_u32_elems(child, "pins");
 
 		if (npinmux > 0 && npins > 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 		if (npinmux == 0 && npins == 0) {
 			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
 				np, child);
-			of_node_put(child);
 			return -EINVAL;
 		}
 
@@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins;
 		int i;
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 			if (!pinmux) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 			if (ret)
-				goto put_child;
+				goto free_map;
 
 			for (i = 0; i < npins; i++) {
 				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
@@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 			if (!pins) {
 				ret = -ENOMEM;
-				goto put_child;
+				goto free_map;
 			}
 
 			pinmux = NULL;
@@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 				ret = of_property_read_u32_index(child, "pins", i, &v);
 				if (ret)
-					goto put_child;
+					goto free_map;
 				pins[i] = v;
 			}
 		} else {
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
 	mutex_unlock(&sfp->mutex);
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);
diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
index 9609eb1ecc3d..4ce080caa233 100644
--- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
+++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
@@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	nmaps = 0;
 	ngroups = 0;
 	mutex_lock(&sfp->mutex);
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		int npins = of_property_count_u32_elems(child, "pinmux");
 		int *pins;
 		u32 *pinmux;
@@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
 				np, child);
 			ret = -EINVAL;
-			goto put_child;
+			goto free_map;
 		}
 
 		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
 		if (!grpname) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pgnames[ngroups++] = grpname;
@@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
 		if (!pins) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
 		if (!pinmux) {
 			ret = -ENOMEM;
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
 		if (ret)
-			goto put_child;
+			goto free_map;
 
 		for (i = 0; i < npins; i++)
 			pins[i] = jh7110_pinmux_pin(pinmux[i]);
@@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 						pins, npins, pinmux);
 		if (ret < 0) {
 			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		ret = pinconf_generic_parse_dt_config(child, pctldev,
@@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 		if (ret) {
 			dev_err(dev, "error parsing pin config of group %s: %d\n",
 				grpname, ret);
-			goto put_child;
+			goto free_map;
 		}
 
 		/* don't create a map if there are no pinconf settings */
@@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = nmaps;
 	return 0;
 
-put_child:
-	of_node_put(child);
 free_map:
 	pinctrl_utils_free_map(pctldev, map, nmaps);
 	mutex_unlock(&sfp->mutex);

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 06/21] pinctrl: sprd: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index d0b6d3e655a2..c4a1d99dfed0 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -934,7 +934,6 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 {
 	struct sprd_pinctrl_soc_info *info = sprd_pctl->info;
 	struct device_node *np = sprd_pctl->dev->of_node;
-	struct device_node *child, *sub_child;
 	struct sprd_pin_group *grp;
 	const char **temp;
 	int ret;
@@ -962,25 +961,20 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 	temp = info->grp_names;
 	grp = info->groups;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sprd_pinctrl_parse_groups(child, sprd_pctl, grp);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 
 		*temp++ = grp->name;
 		grp++;
 
 		if (of_get_child_count(child) > 0) {
-			for_each_child_of_node(child, sub_child) {
+			for_each_child_of_node_scoped(child, sub_child) {
 				ret = sprd_pinctrl_parse_groups(sub_child,
 								sprd_pctl, grp);
-				if (ret) {
-					of_node_put(sub_child);
-					of_node_put(child);
+				if (ret)
 					return ret;
-				}
 
 				*temp++ = grp->name;
 				grp++;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 06/21] pinctrl: sprd: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index d0b6d3e655a2..c4a1d99dfed0 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -934,7 +934,6 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 {
 	struct sprd_pinctrl_soc_info *info = sprd_pctl->info;
 	struct device_node *np = sprd_pctl->dev->of_node;
-	struct device_node *child, *sub_child;
 	struct sprd_pin_group *grp;
 	const char **temp;
 	int ret;
@@ -962,25 +961,20 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 	temp = info->grp_names;
 	grp = info->groups;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sprd_pinctrl_parse_groups(child, sprd_pctl, grp);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 
 		*temp++ = grp->name;
 		grp++;
 
 		if (of_get_child_count(child) > 0) {
-			for_each_child_of_node(child, sub_child) {
+			for_each_child_of_node_scoped(child, sub_child) {
 				ret = sprd_pinctrl_parse_groups(sub_child,
 								sprd_pctl, grp);
-				if (ret) {
-					of_node_put(sub_child);
-					of_node_put(child);
+				if (ret)
 					return ret;
-				}
 
 				*temp++ = grp->name;
 				grp++;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 06/21] pinctrl: sprd: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/sprd/pinctrl-sprd.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index d0b6d3e655a2..c4a1d99dfed0 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -934,7 +934,6 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 {
 	struct sprd_pinctrl_soc_info *info = sprd_pctl->info;
 	struct device_node *np = sprd_pctl->dev->of_node;
-	struct device_node *child, *sub_child;
 	struct sprd_pin_group *grp;
 	const char **temp;
 	int ret;
@@ -962,25 +961,20 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
 	temp = info->grp_names;
 	grp = info->groups;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sprd_pinctrl_parse_groups(child, sprd_pctl, grp);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 
 		*temp++ = grp->name;
 		grp++;
 
 		if (of_get_child_count(child) > 0) {
-			for_each_child_of_node(child, sub_child) {
+			for_each_child_of_node_scoped(child, sub_child) {
 				ret = sprd_pinctrl_parse_groups(sub_child,
 								sprd_pctl, grp);
-				if (ret) {
-					of_node_put(sub_child);
-					of_node_put(child);
+				if (ret)
 					return ret;
-				}
 
 				*temp++ = grp->name;
 				grp++;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 07/21] pinctrl: spear: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/spear/pinctrl-spear.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
index b8caaa5a2d4e..a8c5fe973cd4 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -151,24 +151,19 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *np;
 	struct property *prop;
 	const char *function, *group;
 	int ret, index = 0, count = 0;
 
 	/* calculate number of maps required */
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = of_property_read_string(np, "st,function", &function);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = of_property_count_strings(np, "st,pins");
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		count += ret;
 	}
@@ -182,7 +177,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (!*map)
 		return -ENOMEM;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		of_property_read_string(np, "st,function", &function);
 		of_property_for_each_string(np, "st,pins", prop, group) {
 			(*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 07/21] pinctrl: spear: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/spear/pinctrl-spear.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
index b8caaa5a2d4e..a8c5fe973cd4 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -151,24 +151,19 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *np;
 	struct property *prop;
 	const char *function, *group;
 	int ret, index = 0, count = 0;
 
 	/* calculate number of maps required */
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = of_property_read_string(np, "st,function", &function);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = of_property_count_strings(np, "st,pins");
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		count += ret;
 	}
@@ -182,7 +177,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (!*map)
 		return -ENOMEM;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		of_property_read_string(np, "st,function", &function);
 		of_property_for_each_string(np, "st,pins", prop, group) {
 			(*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 07/21] pinctrl: spear: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/spear/pinctrl-spear.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
index b8caaa5a2d4e..a8c5fe973cd4 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -151,24 +151,19 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 					unsigned *num_maps)
 {
 	struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *np;
 	struct property *prop;
 	const char *function, *group;
 	int ret, index = 0, count = 0;
 
 	/* calculate number of maps required */
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = of_property_read_string(np, "st,function", &function);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = of_property_count_strings(np, "st,pins");
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			return ret;
-		}
 
 		count += ret;
 	}
@@ -182,7 +177,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (!*map)
 		return -ENOMEM;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		of_property_read_string(np, "st,function", &function);
 		of_property_for_each_string(np, "st,pins", prop, group) {
 			(*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
 drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
 drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
 4 files changed, 14 insertions(+), 39 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
index 85ddf49a5188..9a57b3ceb536 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 		       const struct samsung_retention_data *data)
 {
 	struct samsung_retention_ctrl *ctrl;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	void __iomem *clk_base;
 
 	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
@@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 	}
 
 	clk_base = of_iomap(np, 0);
-	of_node_put(np);
 	if (!clk_base) {
 		pr_err("%s: failed to map clock registers\n", __func__);
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 871c1eb46ddf..3775999536e2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -582,7 +582,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
 __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *wkup_np = NULL;
+	struct device_node *wkup_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct exynos_weint_data *weint_data;
@@ -612,17 +612,14 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 
 		bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip),
 					      GFP_KERNEL);
-		if (!bank->irq_chip) {
-			of_node_put(wkup_np);
+		if (!bank->irq_chip)
 			return -ENOMEM;
-		}
 		bank->irq_chip->chip.name = bank->name;
 
 		bank->irq_domain = irq_domain_create_linear(bank->fwnode,
 				bank->nr_pins, &exynos_eint_irqd_ops, bank);
 		if (!bank->irq_domain) {
 			dev_err(dev, "wkup irq domain add failed\n");
-			of_node_put(wkup_np);
 			return -ENXIO;
 		}
 
@@ -635,10 +632,8 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		weint_data = devm_kcalloc(dev,
 					  bank->nr_pins, sizeof(*weint_data),
 					  GFP_KERNEL);
-		if (!weint_data) {
-			of_node_put(wkup_np);
+		if (!weint_data)
 			return -ENOMEM;
-		}
 
 		for (idx = 0; idx < bank->nr_pins; ++idx) {
 			irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx);
@@ -655,13 +650,10 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		}
 	}
 
-	if (!muxed_banks) {
-		of_node_put(wkup_np);
+	if (!muxed_banks)
 		return 0;
-	}
 
 	irq = irq_of_parse_and_map(wkup_np, 0);
-	of_node_put(wkup_np);
 	if (!irq) {
 		dev_err(dev, "irq number for muxed EINTs not found\n");
 		return 0;
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
index c5d92db4fdb1..9acf65eb0f5b 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
@@ -685,7 +685,7 @@ static const struct of_device_id s3c64xx_eint0_irq_ids[] = {
 static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *eint0_np = NULL;
+	struct device_node *eint0_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct s3c64xx_eint0_data *data;
@@ -701,10 +701,8 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		return -ENODEV;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		of_node_put(eint0_np);
+	if (!data)
 		return -ENOMEM;
-	}
 	data->drvdata = d;
 
 	for (i = 0; i < NUM_EINT0_IRQ; ++i) {
@@ -713,7 +711,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		irq = irq_of_parse_and_map(eint0_np, i);
 		if (!irq) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			of_node_put(eint0_np);
 			return -ENXIO;
 		}
 
@@ -721,7 +718,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 						 s3c64xx_eint0_handlers[i],
 						 data);
 	}
-	of_node_put(eint0_np);
 
 	bank = d->pin_banks;
 	for (i = 0; i < d->nr_banks; ++i, ++bank) {
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index ed07e23e0912..4cae112ca15b 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -250,7 +250,6 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct samsung_pinctrl_drv_data *drvdata;
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	drvdata = pinctrl_dev_get_drvdata(pctldev);
@@ -265,12 +264,11 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 							&reserved_maps,
 							num_maps);
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map,
 						&reserved_maps, num_maps);
 		if (ret < 0) {
 			samsung_dt_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -753,7 +751,6 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 {
 	struct samsung_pmx_func *functions, *func;
 	struct device_node *dev_np = dev->of_node;
-	struct device_node *cfg_np;
 	unsigned int func_cnt = 0;
 	int ret;
 
@@ -761,9 +758,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * Iterate over all the child nodes of the pin controller node
 	 * and create pin groups and pin function lists.
 	 */
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			if (!of_find_property(cfg_np,
 			    "samsung,pin-function", NULL))
@@ -772,7 +767,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			if (!of_find_property(func_np,
 			    "samsung,pin-function", NULL))
 				continue;
@@ -791,16 +786,12 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * and create pin groups and pin function lists.
 	 */
 	func_cnt = 0;
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 							cfg_np, func);
-			if (ret < 0) {
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;
@@ -808,14 +799,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 						func_np, func);
-			if (ret < 0) {
-				of_node_put(func_np);
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
 drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
 drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
 4 files changed, 14 insertions(+), 39 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
index 85ddf49a5188..9a57b3ceb536 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 		       const struct samsung_retention_data *data)
 {
 	struct samsung_retention_ctrl *ctrl;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	void __iomem *clk_base;
 
 	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
@@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 	}
 
 	clk_base = of_iomap(np, 0);
-	of_node_put(np);
 	if (!clk_base) {
 		pr_err("%s: failed to map clock registers\n", __func__);
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 871c1eb46ddf..3775999536e2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -582,7 +582,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
 __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *wkup_np = NULL;
+	struct device_node *wkup_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct exynos_weint_data *weint_data;
@@ -612,17 +612,14 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 
 		bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip),
 					      GFP_KERNEL);
-		if (!bank->irq_chip) {
-			of_node_put(wkup_np);
+		if (!bank->irq_chip)
 			return -ENOMEM;
-		}
 		bank->irq_chip->chip.name = bank->name;
 
 		bank->irq_domain = irq_domain_create_linear(bank->fwnode,
 				bank->nr_pins, &exynos_eint_irqd_ops, bank);
 		if (!bank->irq_domain) {
 			dev_err(dev, "wkup irq domain add failed\n");
-			of_node_put(wkup_np);
 			return -ENXIO;
 		}
 
@@ -635,10 +632,8 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		weint_data = devm_kcalloc(dev,
 					  bank->nr_pins, sizeof(*weint_data),
 					  GFP_KERNEL);
-		if (!weint_data) {
-			of_node_put(wkup_np);
+		if (!weint_data)
 			return -ENOMEM;
-		}
 
 		for (idx = 0; idx < bank->nr_pins; ++idx) {
 			irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx);
@@ -655,13 +650,10 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		}
 	}
 
-	if (!muxed_banks) {
-		of_node_put(wkup_np);
+	if (!muxed_banks)
 		return 0;
-	}
 
 	irq = irq_of_parse_and_map(wkup_np, 0);
-	of_node_put(wkup_np);
 	if (!irq) {
 		dev_err(dev, "irq number for muxed EINTs not found\n");
 		return 0;
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
index c5d92db4fdb1..9acf65eb0f5b 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
@@ -685,7 +685,7 @@ static const struct of_device_id s3c64xx_eint0_irq_ids[] = {
 static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *eint0_np = NULL;
+	struct device_node *eint0_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct s3c64xx_eint0_data *data;
@@ -701,10 +701,8 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		return -ENODEV;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		of_node_put(eint0_np);
+	if (!data)
 		return -ENOMEM;
-	}
 	data->drvdata = d;
 
 	for (i = 0; i < NUM_EINT0_IRQ; ++i) {
@@ -713,7 +711,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		irq = irq_of_parse_and_map(eint0_np, i);
 		if (!irq) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			of_node_put(eint0_np);
 			return -ENXIO;
 		}
 
@@ -721,7 +718,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 						 s3c64xx_eint0_handlers[i],
 						 data);
 	}
-	of_node_put(eint0_np);
 
 	bank = d->pin_banks;
 	for (i = 0; i < d->nr_banks; ++i, ++bank) {
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index ed07e23e0912..4cae112ca15b 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -250,7 +250,6 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct samsung_pinctrl_drv_data *drvdata;
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	drvdata = pinctrl_dev_get_drvdata(pctldev);
@@ -265,12 +264,11 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 							&reserved_maps,
 							num_maps);
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map,
 						&reserved_maps, num_maps);
 		if (ret < 0) {
 			samsung_dt_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -753,7 +751,6 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 {
 	struct samsung_pmx_func *functions, *func;
 	struct device_node *dev_np = dev->of_node;
-	struct device_node *cfg_np;
 	unsigned int func_cnt = 0;
 	int ret;
 
@@ -761,9 +758,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * Iterate over all the child nodes of the pin controller node
 	 * and create pin groups and pin function lists.
 	 */
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			if (!of_find_property(cfg_np,
 			    "samsung,pin-function", NULL))
@@ -772,7 +767,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			if (!of_find_property(func_np,
 			    "samsung,pin-function", NULL))
 				continue;
@@ -791,16 +786,12 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * and create pin groups and pin function lists.
 	 */
 	func_cnt = 0;
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 							cfg_np, func);
-			if (ret < 0) {
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;
@@ -808,14 +799,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 						func_np, func);
-			if (ret < 0) {
-				of_node_put(func_np);
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
 drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
 drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
 drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
 4 files changed, 14 insertions(+), 39 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
index 85ddf49a5188..9a57b3ceb536 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
@@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 		       const struct samsung_retention_data *data)
 {
 	struct samsung_retention_ctrl *ctrl;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	void __iomem *clk_base;
 
 	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
@@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
 	}
 
 	clk_base = of_iomap(np, 0);
-	of_node_put(np);
 	if (!clk_base) {
 		pr_err("%s: failed to map clock registers\n", __func__);
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 871c1eb46ddf..3775999536e2 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -582,7 +582,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
 __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *wkup_np = NULL;
+	struct device_node *wkup_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct exynos_weint_data *weint_data;
@@ -612,17 +612,14 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 
 		bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip),
 					      GFP_KERNEL);
-		if (!bank->irq_chip) {
-			of_node_put(wkup_np);
+		if (!bank->irq_chip)
 			return -ENOMEM;
-		}
 		bank->irq_chip->chip.name = bank->name;
 
 		bank->irq_domain = irq_domain_create_linear(bank->fwnode,
 				bank->nr_pins, &exynos_eint_irqd_ops, bank);
 		if (!bank->irq_domain) {
 			dev_err(dev, "wkup irq domain add failed\n");
-			of_node_put(wkup_np);
 			return -ENXIO;
 		}
 
@@ -635,10 +632,8 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		weint_data = devm_kcalloc(dev,
 					  bank->nr_pins, sizeof(*weint_data),
 					  GFP_KERNEL);
-		if (!weint_data) {
-			of_node_put(wkup_np);
+		if (!weint_data)
 			return -ENOMEM;
-		}
 
 		for (idx = 0; idx < bank->nr_pins; ++idx) {
 			irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx);
@@ -655,13 +650,10 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
 		}
 	}
 
-	if (!muxed_banks) {
-		of_node_put(wkup_np);
+	if (!muxed_banks)
 		return 0;
-	}
 
 	irq = irq_of_parse_and_map(wkup_np, 0);
-	of_node_put(wkup_np);
 	if (!irq) {
 		dev_err(dev, "irq number for muxed EINTs not found\n");
 		return 0;
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
index c5d92db4fdb1..9acf65eb0f5b 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
@@ -685,7 +685,7 @@ static const struct of_device_id s3c64xx_eint0_irq_ids[] = {
 static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 {
 	struct device *dev = d->dev;
-	struct device_node *eint0_np = NULL;
+	struct device_node *eint0_np __free(device_node) = NULL;
 	struct device_node *np;
 	struct samsung_pin_bank *bank;
 	struct s3c64xx_eint0_data *data;
@@ -701,10 +701,8 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		return -ENODEV;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		of_node_put(eint0_np);
+	if (!data)
 		return -ENOMEM;
-	}
 	data->drvdata = d;
 
 	for (i = 0; i < NUM_EINT0_IRQ; ++i) {
@@ -713,7 +711,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 		irq = irq_of_parse_and_map(eint0_np, i);
 		if (!irq) {
 			dev_err(dev, "failed to get wakeup EINT IRQ %d\n", i);
-			of_node_put(eint0_np);
 			return -ENXIO;
 		}
 
@@ -721,7 +718,6 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
 						 s3c64xx_eint0_handlers[i],
 						 data);
 	}
-	of_node_put(eint0_np);
 
 	bank = d->pin_banks;
 	for (i = 0; i < d->nr_banks; ++i, ++bank) {
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index ed07e23e0912..4cae112ca15b 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -250,7 +250,6 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct samsung_pinctrl_drv_data *drvdata;
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	drvdata = pinctrl_dev_get_drvdata(pctldev);
@@ -265,12 +264,11 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
 							&reserved_maps,
 							num_maps);
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map,
 						&reserved_maps, num_maps);
 		if (ret < 0) {
 			samsung_dt_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
@@ -753,7 +751,6 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 {
 	struct samsung_pmx_func *functions, *func;
 	struct device_node *dev_np = dev->of_node;
-	struct device_node *cfg_np;
 	unsigned int func_cnt = 0;
 	int ret;
 
@@ -761,9 +758,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * Iterate over all the child nodes of the pin controller node
 	 * and create pin groups and pin function lists.
 	 */
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			if (!of_find_property(cfg_np,
 			    "samsung,pin-function", NULL))
@@ -772,7 +767,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			if (!of_find_property(func_np,
 			    "samsung,pin-function", NULL))
 				continue;
@@ -791,16 +786,12 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 	 * and create pin groups and pin function lists.
 	 */
 	func_cnt = 0;
-	for_each_child_of_node(dev_np, cfg_np) {
-		struct device_node *func_np;
-
+	for_each_child_of_node_scoped(dev_np, cfg_np) {
 		if (!of_get_child_count(cfg_np)) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 							cfg_np, func);
-			if (ret < 0) {
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;
@@ -808,14 +799,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
 			continue;
 		}
 
-		for_each_child_of_node(cfg_np, func_np) {
+		for_each_child_of_node_scoped(cfg_np, func_np) {
 			ret = samsung_pinctrl_create_function(dev, drvdata,
 						func_np, func);
-			if (ret < 0) {
-				of_node_put(func_np);
-				of_node_put(cfg_np);
+			if (ret < 0)
 				return ERR_PTR(ret);
-			}
 			if (ret > 0) {
 				++func;
 				++func_cnt;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 09/21] pinctrl: renesas: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/renesas/pinctrl-rza1.c  | 14 ++++----------
 drivers/pinctrl/renesas/pinctrl-rzg2l.c | 10 +++-------
 drivers/pinctrl/renesas/pinctrl-rzn1.c  | 23 +++++++----------------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c |  7 ++-----
 drivers/pinctrl/renesas/pinctrl.c       |  7 ++-----
 5 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index edcbe7c9ad56..6527872813dc 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -852,7 +852,6 @@ static const struct gpio_chip rza1_gpiochip_template = {
  */
 static int rza1_dt_node_pin_count(struct device_node *np)
 {
-	struct device_node *child;
 	struct property *of_pins;
 	unsigned int npins;
 
@@ -861,12 +860,10 @@ static int rza1_dt_node_pin_count(struct device_node *np)
 		return of_pins->length / sizeof(u32);
 
 	npins = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		of_pins = of_find_property(child, "pinmux", NULL);
-		if (!of_pins) {
-			of_node_put(child);
+		if (!of_pins)
 			return -EINVAL;
-		}
 
 		npins += of_pins->length / sizeof(u32);
 	}
@@ -986,7 +983,6 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct rza1_pinctrl *rza1_pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct rza1_mux_conf *mux_confs, *mux_conf;
 	unsigned int *grpins, *grpin;
-	struct device_node *child;
 	const char *grpname;
 	const char **fngrps;
 	int ret, npins;
@@ -1023,13 +1019,11 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	ret = rza1_parse_pinmux_node(rza1_pctl, np, mux_conf, grpin);
 	if (ret == -ENOENT)
-		for_each_child_of_node(np, child) {
+		for_each_child_of_node_scoped(np, child) {
 			ret = rza1_parse_pinmux_node(rza1_pctl, child, mux_conf,
 						     grpin);
-			if (ret < 0) {
-				of_node_put(child);
+			if (ret < 0)
 				return ret;
-			}
 
 			grpin += ret;
 			mux_conf += ret;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index c3256bfde502..85a4f3c7d73c 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -745,7 +745,6 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -753,13 +752,11 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzg2l_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
@@ -2201,7 +2198,7 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 	const char *name = dev_name(pctrl->dev);
 	struct irq_domain *parent_domain;
 	struct of_phandle_args of_args;
-	struct device_node *parent_np;
+	struct device_node *parent_np __free(device_node) = of_irq_find_parent(np);
 	struct gpio_irq_chip *girq;
 	int ret;
 
@@ -2210,7 +2207,6 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 		return -ENXIO;
 
 	parent_domain = irq_find_host(parent_np);
-	of_node_put(parent_np);
 	if (!parent_domain)
 		return -EPROBE_DEFER;
 
diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c
index 4b2f107824fe..e1b4203c66c6 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
@@ -404,7 +404,6 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 			       struct pinctrl_map **map,
 			       unsigned int *num_maps)
 {
-	struct device_node *child;
 	int ret;
 
 	*map = NULL;
@@ -414,12 +413,10 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		return ret;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_dt_node_to_map_one(pctldev, child, map, num_maps);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -760,7 +757,6 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 {
 	struct rzn1_pmx_func *func;
 	struct rzn1_pin_group *grp;
-	struct device_node *child;
 	unsigned int i = 0;
 	int ret;
 
@@ -793,15 +789,13 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 		ipctl->ngroups++;
 	}
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &ipctl->groups[ipctl->ngroups];
 		grp->func = func->name;
 		ret = rzn1_pinctrl_parse_groups(child, grp, ipctl);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 		i++;
 		ipctl->ngroups++;
 	}
@@ -816,7 +810,6 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 				 struct rzn1_pinctrl *ipctl)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	unsigned int maxgroups = 0;
 	unsigned int i = 0;
 	int nfuncs = 0;
@@ -834,7 +827,7 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	ipctl->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		maxgroups += rzn1_pinctrl_count_function_groups(child);
 
 	ipctl->groups = devm_kmalloc_array(&pdev->dev,
@@ -844,12 +837,10 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 	if (!ipctl->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_pinctrl_parse_functions(child, ipctl, i++);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index 0767a5ac23e0..0cae5472ac67 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -388,7 +388,6 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzv2m_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -396,13 +395,11 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzv2m_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c
index 4d9d58fc1356..03e9bdbc82b9 100644
--- a/drivers/pinctrl/renesas/pinctrl.c
+++ b/drivers/pinctrl/renesas/pinctrl.c
@@ -241,7 +241,6 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = pmx->pfc->dev;
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -249,13 +248,11 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps,
 					       &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	/* If no mapping has been found in child nodes try the config node. */

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 09/21] pinctrl: renesas: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/renesas/pinctrl-rza1.c  | 14 ++++----------
 drivers/pinctrl/renesas/pinctrl-rzg2l.c | 10 +++-------
 drivers/pinctrl/renesas/pinctrl-rzn1.c  | 23 +++++++----------------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c |  7 ++-----
 drivers/pinctrl/renesas/pinctrl.c       |  7 ++-----
 5 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index edcbe7c9ad56..6527872813dc 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -852,7 +852,6 @@ static const struct gpio_chip rza1_gpiochip_template = {
  */
 static int rza1_dt_node_pin_count(struct device_node *np)
 {
-	struct device_node *child;
 	struct property *of_pins;
 	unsigned int npins;
 
@@ -861,12 +860,10 @@ static int rza1_dt_node_pin_count(struct device_node *np)
 		return of_pins->length / sizeof(u32);
 
 	npins = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		of_pins = of_find_property(child, "pinmux", NULL);
-		if (!of_pins) {
-			of_node_put(child);
+		if (!of_pins)
 			return -EINVAL;
-		}
 
 		npins += of_pins->length / sizeof(u32);
 	}
@@ -986,7 +983,6 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct rza1_pinctrl *rza1_pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct rza1_mux_conf *mux_confs, *mux_conf;
 	unsigned int *grpins, *grpin;
-	struct device_node *child;
 	const char *grpname;
 	const char **fngrps;
 	int ret, npins;
@@ -1023,13 +1019,11 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	ret = rza1_parse_pinmux_node(rza1_pctl, np, mux_conf, grpin);
 	if (ret == -ENOENT)
-		for_each_child_of_node(np, child) {
+		for_each_child_of_node_scoped(np, child) {
 			ret = rza1_parse_pinmux_node(rza1_pctl, child, mux_conf,
 						     grpin);
-			if (ret < 0) {
-				of_node_put(child);
+			if (ret < 0)
 				return ret;
-			}
 
 			grpin += ret;
 			mux_conf += ret;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index c3256bfde502..85a4f3c7d73c 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -745,7 +745,6 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -753,13 +752,11 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzg2l_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
@@ -2201,7 +2198,7 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 	const char *name = dev_name(pctrl->dev);
 	struct irq_domain *parent_domain;
 	struct of_phandle_args of_args;
-	struct device_node *parent_np;
+	struct device_node *parent_np __free(device_node) = of_irq_find_parent(np);
 	struct gpio_irq_chip *girq;
 	int ret;
 
@@ -2210,7 +2207,6 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 		return -ENXIO;
 
 	parent_domain = irq_find_host(parent_np);
-	of_node_put(parent_np);
 	if (!parent_domain)
 		return -EPROBE_DEFER;
 
diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c
index 4b2f107824fe..e1b4203c66c6 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
@@ -404,7 +404,6 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 			       struct pinctrl_map **map,
 			       unsigned int *num_maps)
 {
-	struct device_node *child;
 	int ret;
 
 	*map = NULL;
@@ -414,12 +413,10 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		return ret;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_dt_node_to_map_one(pctldev, child, map, num_maps);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -760,7 +757,6 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 {
 	struct rzn1_pmx_func *func;
 	struct rzn1_pin_group *grp;
-	struct device_node *child;
 	unsigned int i = 0;
 	int ret;
 
@@ -793,15 +789,13 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 		ipctl->ngroups++;
 	}
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &ipctl->groups[ipctl->ngroups];
 		grp->func = func->name;
 		ret = rzn1_pinctrl_parse_groups(child, grp, ipctl);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 		i++;
 		ipctl->ngroups++;
 	}
@@ -816,7 +810,6 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 				 struct rzn1_pinctrl *ipctl)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	unsigned int maxgroups = 0;
 	unsigned int i = 0;
 	int nfuncs = 0;
@@ -834,7 +827,7 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	ipctl->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		maxgroups += rzn1_pinctrl_count_function_groups(child);
 
 	ipctl->groups = devm_kmalloc_array(&pdev->dev,
@@ -844,12 +837,10 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 	if (!ipctl->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_pinctrl_parse_functions(child, ipctl, i++);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index 0767a5ac23e0..0cae5472ac67 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -388,7 +388,6 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzv2m_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -396,13 +395,11 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzv2m_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c
index 4d9d58fc1356..03e9bdbc82b9 100644
--- a/drivers/pinctrl/renesas/pinctrl.c
+++ b/drivers/pinctrl/renesas/pinctrl.c
@@ -241,7 +241,6 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = pmx->pfc->dev;
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -249,13 +248,11 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps,
 					       &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	/* If no mapping has been found in child nodes try the config node. */

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 09/21] pinctrl: renesas: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/renesas/pinctrl-rza1.c  | 14 ++++----------
 drivers/pinctrl/renesas/pinctrl-rzg2l.c | 10 +++-------
 drivers/pinctrl/renesas/pinctrl-rzn1.c  | 23 +++++++----------------
 drivers/pinctrl/renesas/pinctrl-rzv2m.c |  7 ++-----
 drivers/pinctrl/renesas/pinctrl.c       |  7 ++-----
 5 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index edcbe7c9ad56..6527872813dc 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -852,7 +852,6 @@ static const struct gpio_chip rza1_gpiochip_template = {
  */
 static int rza1_dt_node_pin_count(struct device_node *np)
 {
-	struct device_node *child;
 	struct property *of_pins;
 	unsigned int npins;
 
@@ -861,12 +860,10 @@ static int rza1_dt_node_pin_count(struct device_node *np)
 		return of_pins->length / sizeof(u32);
 
 	npins = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		of_pins = of_find_property(child, "pinmux", NULL);
-		if (!of_pins) {
-			of_node_put(child);
+		if (!of_pins)
 			return -EINVAL;
-		}
 
 		npins += of_pins->length / sizeof(u32);
 	}
@@ -986,7 +983,6 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct rza1_pinctrl *rza1_pctl = pinctrl_dev_get_drvdata(pctldev);
 	struct rza1_mux_conf *mux_confs, *mux_conf;
 	unsigned int *grpins, *grpin;
-	struct device_node *child;
 	const char *grpname;
 	const char **fngrps;
 	int ret, npins;
@@ -1023,13 +1019,11 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
 
 	ret = rza1_parse_pinmux_node(rza1_pctl, np, mux_conf, grpin);
 	if (ret == -ENOENT)
-		for_each_child_of_node(np, child) {
+		for_each_child_of_node_scoped(np, child) {
 			ret = rza1_parse_pinmux_node(rza1_pctl, child, mux_conf,
 						     grpin);
-			if (ret < 0) {
-				of_node_put(child);
+			if (ret < 0)
 				return ret;
-			}
 
 			grpin += ret;
 			mux_conf += ret;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index c3256bfde502..85a4f3c7d73c 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -745,7 +745,6 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -753,13 +752,11 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzg2l_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
@@ -2201,7 +2198,7 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 	const char *name = dev_name(pctrl->dev);
 	struct irq_domain *parent_domain;
 	struct of_phandle_args of_args;
-	struct device_node *parent_np;
+	struct device_node *parent_np __free(device_node) = of_irq_find_parent(np);
 	struct gpio_irq_chip *girq;
 	int ret;
 
@@ -2210,7 +2207,6 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl)
 		return -ENXIO;
 
 	parent_domain = irq_find_host(parent_np);
-	of_node_put(parent_np);
 	if (!parent_domain)
 		return -EPROBE_DEFER;
 
diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c
index 4b2f107824fe..e1b4203c66c6 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
@@ -404,7 +404,6 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 			       struct pinctrl_map **map,
 			       unsigned int *num_maps)
 {
-	struct device_node *child;
 	int ret;
 
 	*map = NULL;
@@ -414,12 +413,10 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		return ret;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_dt_node_to_map_one(pctldev, child, map, num_maps);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -760,7 +757,6 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 {
 	struct rzn1_pmx_func *func;
 	struct rzn1_pin_group *grp;
-	struct device_node *child;
 	unsigned int i = 0;
 	int ret;
 
@@ -793,15 +789,13 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np,
 		ipctl->ngroups++;
 	}
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &ipctl->groups[ipctl->ngroups];
 		grp->func = func->name;
 		ret = rzn1_pinctrl_parse_groups(child, grp, ipctl);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 		i++;
 		ipctl->ngroups++;
 	}
@@ -816,7 +810,6 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 				 struct rzn1_pinctrl *ipctl)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	unsigned int maxgroups = 0;
 	unsigned int i = 0;
 	int nfuncs = 0;
@@ -834,7 +827,7 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	ipctl->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		maxgroups += rzn1_pinctrl_count_function_groups(child);
 
 	ipctl->groups = devm_kmalloc_array(&pdev->dev,
@@ -844,12 +837,10 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev,
 	if (!ipctl->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzn1_pinctrl_parse_functions(child, ipctl, i++);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index 0767a5ac23e0..0cae5472ac67 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -388,7 +388,6 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 				unsigned int *num_maps)
 {
 	struct rzv2m_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -396,13 +395,11 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = rzv2m_dt_subnode_to_map(pctldev, child, np, map,
 					      num_maps, &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	if (*num_maps == 0) {
diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c
index 4d9d58fc1356..03e9bdbc82b9 100644
--- a/drivers/pinctrl/renesas/pinctrl.c
+++ b/drivers/pinctrl/renesas/pinctrl.c
@@ -241,7 +241,6 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 {
 	struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
 	struct device *dev = pmx->pfc->dev;
-	struct device_node *child;
 	unsigned int index;
 	int ret;
 
@@ -249,13 +248,11 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	index = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps,
 					       &index);
-		if (ret < 0) {
-			of_node_put(child);
+		if (ret < 0)
 			goto done;
-		}
 	}
 
 	/* If no mapping has been found in child nodes try the config node. */

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-st.c | 40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 5d9abd6547d0..2d77160f3654 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -812,7 +812,7 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct st_pctl_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num, i;
 
 	grp = st_pctl_find_group_by_name(info, np->name);
@@ -837,7 +837,6 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map per pin */
 	new_map++;
@@ -1161,7 +1160,7 @@ static void st_parse_syscfgs(struct st_pinctrl *info, int bank,
 static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 				    phandle bank, unsigned int offset)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct gpio_chip *chip;
 	int retval = -EINVAL;
 	int i;
@@ -1179,7 +1178,6 @@ static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 		}
 	}
 
-	of_node_put(np);
 	return retval;
 }
 
@@ -1195,10 +1193,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	struct property *pp;
 	struct device *dev = info->dev;
 	struct st_pinconf *conf;
-	struct device_node *pins;
+	struct device_node *pins __free(device_node) = NULL;
 	phandle bank;
 	unsigned int offset;
-	int i = 0, npins = 0, nr_props, ret = 0;
+	int i = 0, npins = 0, nr_props;
 
 	pins = of_get_child_by_name(np, "st,pins");
 	if (!pins)
@@ -1213,8 +1211,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 			npins++;
 		} else {
 			pr_warn("Invalid st,pins in %pOFn node\n", np);
-			ret = -EINVAL;
-			goto out_put_node;
+			return -EINVAL;
 		}
 	}
 
@@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
 
 	if (!grp->pins || !grp->pin_conf) {
-		ret = -ENOMEM;
-		goto out_put_node;
+		return -ENOMEM;
 	}
 
 	/* <bank offset mux direction rt_type rt_delay rt_clk> */
@@ -1260,17 +1256,13 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 		i++;
 	}
 
-out_put_node:
-	of_node_put(pins);
-
-	return ret;
+	return 0;
 }
 
 static int st_pctl_parse_functions(struct device_node *np,
 			struct st_pinctrl *info, u32 index, int *grp_index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct st_pmx_func *func;
 	struct st_pctl_group *grp;
 	int ret, i;
@@ -1285,15 +1277,13 @@ static int st_pctl_parse_functions(struct device_node *np,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[*grp_index];
 		*grp_index += 1;
 		ret = st_pctl_dt_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 	dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups);
 
@@ -1601,7 +1591,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	int i = 0, j = 0, k = 0, bank;
 	struct pinctrl_pin_desc *pdesc;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int grp_index = 0;
 	int irq = 0;
 
@@ -1646,25 +1635,21 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	pctl_desc->pins = pdesc;
 
 	bank = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_property_read_bool(child, "gpio-controller")) {
 			const char *bank_name = NULL;
 			char **pin_names;
 
 			ret = st_gpiolib_register_bank(info, bank, child);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 
 			k = info->banks[bank].range.pin_base;
 			bank_name = info->banks[bank].range.name;
 
 			pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
-			if (IS_ERR(pin_names)) {
-				of_node_put(child);
+			if (IS_ERR(pin_names))
 				return PTR_ERR(pin_names);
-			}
 
 			for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) {
 				pdesc->number = k;
@@ -1678,7 +1663,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 							i++, &grp_index);
 			if (ret) {
 				dev_err(dev, "No functions found.\n");
-				of_node_put(child);
 				return ret;
 			}
 		}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-st.c | 40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 5d9abd6547d0..2d77160f3654 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -812,7 +812,7 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct st_pctl_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num, i;
 
 	grp = st_pctl_find_group_by_name(info, np->name);
@@ -837,7 +837,6 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map per pin */
 	new_map++;
@@ -1161,7 +1160,7 @@ static void st_parse_syscfgs(struct st_pinctrl *info, int bank,
 static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 				    phandle bank, unsigned int offset)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct gpio_chip *chip;
 	int retval = -EINVAL;
 	int i;
@@ -1179,7 +1178,6 @@ static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 		}
 	}
 
-	of_node_put(np);
 	return retval;
 }
 
@@ -1195,10 +1193,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	struct property *pp;
 	struct device *dev = info->dev;
 	struct st_pinconf *conf;
-	struct device_node *pins;
+	struct device_node *pins __free(device_node) = NULL;
 	phandle bank;
 	unsigned int offset;
-	int i = 0, npins = 0, nr_props, ret = 0;
+	int i = 0, npins = 0, nr_props;
 
 	pins = of_get_child_by_name(np, "st,pins");
 	if (!pins)
@@ -1213,8 +1211,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 			npins++;
 		} else {
 			pr_warn("Invalid st,pins in %pOFn node\n", np);
-			ret = -EINVAL;
-			goto out_put_node;
+			return -EINVAL;
 		}
 	}
 
@@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
 
 	if (!grp->pins || !grp->pin_conf) {
-		ret = -ENOMEM;
-		goto out_put_node;
+		return -ENOMEM;
 	}
 
 	/* <bank offset mux direction rt_type rt_delay rt_clk> */
@@ -1260,17 +1256,13 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 		i++;
 	}
 
-out_put_node:
-	of_node_put(pins);
-
-	return ret;
+	return 0;
 }
 
 static int st_pctl_parse_functions(struct device_node *np,
 			struct st_pinctrl *info, u32 index, int *grp_index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct st_pmx_func *func;
 	struct st_pctl_group *grp;
 	int ret, i;
@@ -1285,15 +1277,13 @@ static int st_pctl_parse_functions(struct device_node *np,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[*grp_index];
 		*grp_index += 1;
 		ret = st_pctl_dt_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 	dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups);
 
@@ -1601,7 +1591,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	int i = 0, j = 0, k = 0, bank;
 	struct pinctrl_pin_desc *pdesc;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int grp_index = 0;
 	int irq = 0;
 
@@ -1646,25 +1635,21 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	pctl_desc->pins = pdesc;
 
 	bank = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_property_read_bool(child, "gpio-controller")) {
 			const char *bank_name = NULL;
 			char **pin_names;
 
 			ret = st_gpiolib_register_bank(info, bank, child);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 
 			k = info->banks[bank].range.pin_base;
 			bank_name = info->banks[bank].range.name;
 
 			pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
-			if (IS_ERR(pin_names)) {
-				of_node_put(child);
+			if (IS_ERR(pin_names))
 				return PTR_ERR(pin_names);
-			}
 
 			for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) {
 				pdesc->number = k;
@@ -1678,7 +1663,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 							i++, &grp_index);
 			if (ret) {
 				dev_err(dev, "No functions found.\n");
-				of_node_put(child);
 				return ret;
 			}
 		}

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-st.c | 40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 5d9abd6547d0..2d77160f3654 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -812,7 +812,7 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct st_pctl_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num, i;
 
 	grp = st_pctl_find_group_by_name(info, np->name);
@@ -837,7 +837,6 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map per pin */
 	new_map++;
@@ -1161,7 +1160,7 @@ static void st_parse_syscfgs(struct st_pinctrl *info, int bank,
 static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 				    phandle bank, unsigned int offset)
 {
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct gpio_chip *chip;
 	int retval = -EINVAL;
 	int i;
@@ -1179,7 +1178,6 @@ static int st_pctl_dt_calculate_pin(struct st_pinctrl *info,
 		}
 	}
 
-	of_node_put(np);
 	return retval;
 }
 
@@ -1195,10 +1193,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	struct property *pp;
 	struct device *dev = info->dev;
 	struct st_pinconf *conf;
-	struct device_node *pins;
+	struct device_node *pins __free(device_node) = NULL;
 	phandle bank;
 	unsigned int offset;
-	int i = 0, npins = 0, nr_props, ret = 0;
+	int i = 0, npins = 0, nr_props;
 
 	pins = of_get_child_by_name(np, "st,pins");
 	if (!pins)
@@ -1213,8 +1211,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 			npins++;
 		} else {
 			pr_warn("Invalid st,pins in %pOFn node\n", np);
-			ret = -EINVAL;
-			goto out_put_node;
+			return -EINVAL;
 		}
 	}
 
@@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
 
 	if (!grp->pins || !grp->pin_conf) {
-		ret = -ENOMEM;
-		goto out_put_node;
+		return -ENOMEM;
 	}
 
 	/* <bank offset mux direction rt_type rt_delay rt_clk> */
@@ -1260,17 +1256,13 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 		i++;
 	}
 
-out_put_node:
-	of_node_put(pins);
-
-	return ret;
+	return 0;
 }
 
 static int st_pctl_parse_functions(struct device_node *np,
 			struct st_pinctrl *info, u32 index, int *grp_index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct st_pmx_func *func;
 	struct st_pctl_group *grp;
 	int ret, i;
@@ -1285,15 +1277,13 @@ static int st_pctl_parse_functions(struct device_node *np,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[*grp_index];
 		*grp_index += 1;
 		ret = st_pctl_dt_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 	dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups);
 
@@ -1601,7 +1591,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	int i = 0, j = 0, k = 0, bank;
 	struct pinctrl_pin_desc *pdesc;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int grp_index = 0;
 	int irq = 0;
 
@@ -1646,25 +1635,21 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 	pctl_desc->pins = pdesc;
 
 	bank = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_property_read_bool(child, "gpio-controller")) {
 			const char *bank_name = NULL;
 			char **pin_names;
 
 			ret = st_gpiolib_register_bank(info, bank, child);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 
 			k = info->banks[bank].range.pin_base;
 			bank_name = info->banks[bank].range.name;
 
 			pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK);
-			if (IS_ERR(pin_names)) {
-				of_node_put(child);
+			if (IS_ERR(pin_names))
 				return PTR_ERR(pin_names);
-			}
 
 			for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) {
 				pdesc->number = k;
@@ -1678,7 +1663,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
 							i++, &grp_index);
 			if (ret) {
 				dev_err(dev, "No functions found.\n");
-				of_node_put(child);
 				return ret;
 			}
 		}

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 11/21] pinctrl: rockchip: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-rockchip.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 3bedf36a0019..5c09469c84d7 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -326,7 +326,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct rockchip_pin_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -358,7 +358,6 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -3057,7 +3056,6 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 						u32 index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct rockchip_pmx_func *func;
 	struct rockchip_pin_group *grp;
 	int ret;
@@ -3078,14 +3076,12 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = rockchip_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -3096,7 +3092,6 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int ret;
 	int i;
 
@@ -3115,14 +3110,13 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_match_node(rockchip_bank_match, child))
 			continue;
 
 		ret = rockchip_pinctrl_parse_functions(child, info, i++);
 		if (ret) {
 			dev_err(dev, "failed to parse function\n");
-			of_node_put(child);
 			return ret;
 		}
 	}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 11/21] pinctrl: rockchip: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-rockchip.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 3bedf36a0019..5c09469c84d7 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -326,7 +326,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct rockchip_pin_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -358,7 +358,6 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -3057,7 +3056,6 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 						u32 index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct rockchip_pmx_func *func;
 	struct rockchip_pin_group *grp;
 	int ret;
@@ -3078,14 +3076,12 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = rockchip_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -3096,7 +3092,6 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int ret;
 	int i;
 
@@ -3115,14 +3110,13 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_match_node(rockchip_bank_match, child))
 			continue;
 
 		ret = rockchip_pinctrl_parse_functions(child, info, i++);
 		if (ret) {
 			dev_err(dev, "failed to parse function\n");
-			of_node_put(child);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 11/21] pinctrl: rockchip: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-rockchip.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 3bedf36a0019..5c09469c84d7 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -326,7 +326,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct rockchip_pin_group *grp;
 	struct device *dev = info->dev;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -358,7 +358,6 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -3057,7 +3056,6 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 						u32 index)
 {
 	struct device *dev = info->dev;
-	struct device_node *child;
 	struct rockchip_pmx_func *func;
 	struct rockchip_pin_group *grp;
 	int ret;
@@ -3078,14 +3076,12 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = rockchip_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -3096,7 +3092,6 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 	int ret;
 	int i;
 
@@ -3115,14 +3110,13 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_match_node(rockchip_bank_match, child))
 			continue;
 
 		ret = rockchip_pinctrl_parse_functions(child, info, i++);
 		if (ret) {
 			dev_err(dev, "failed to parse function\n");
-			of_node_put(child);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-k210.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
index b6d1ed9ec9a3..2753e14c3e38 100644
--- a/drivers/pinctrl/pinctrl-k210.c
+++ b/drivers/pinctrl/pinctrl-k210.c
@@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				       unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto err;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						     &reserved_maps, num_maps);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto err;
-		}
 	}
 	return 0;
 

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-k210.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
index b6d1ed9ec9a3..2753e14c3e38 100644
--- a/drivers/pinctrl/pinctrl-k210.c
+++ b/drivers/pinctrl/pinctrl-k210.c
@@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				       unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto err;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						     &reserved_maps, num_maps);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto err;
-		}
 	}
 	return 0;
 

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-k210.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
index b6d1ed9ec9a3..2753e14c3e38 100644
--- a/drivers/pinctrl/pinctrl-k210.c
+++ b/drivers/pinctrl/pinctrl-k210.c
@@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				       unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto err;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						     &reserved_maps, num_maps);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto err;
-		}
 	}
 	return 0;
 

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 13/21] pinctrl: equilibrium: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-equilibrium.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c
index 6e1be38865c3..e727257bb697 100644
--- a/drivers/pinctrl/pinctrl-equilibrium.c
+++ b/drivers/pinctrl/pinctrl-equilibrium.c
@@ -588,14 +588,13 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 		       unsigned int *nr_funcs, funcs_util_ops op)
 {
 	struct device_node *node = dev->of_node;
-	struct device_node *np;
 	struct property *prop;
 	const char *fn_name;
 	unsigned int fid;
 	int i, j;
 
 	i = 0;
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -633,7 +632,6 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 			break;
 
 		default:
-			of_node_put(np);
 			return -EINVAL;
 		}
 		i++;
@@ -706,11 +704,10 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 	struct device_node *node = dev->of_node;
 	unsigned int *pins, *pinmux, pin_id, pinmux_id;
 	struct pingroup group, *grp = &group;
-	struct device_node *np;
 	struct property *prop;
 	int j, err;
 
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -718,42 +715,35 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 		err = of_property_count_u32_elems(np, "pins");
 		if (err < 0) {
 			dev_err(dev, "No pins in the group: %s\n", prop->name);
-			of_node_put(np);
 			return err;
 		}
 		grp->npins = err;
 		grp->name = prop->value;
 		pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL);
-		if (!pins) {
-			of_node_put(np);
+		if (!pins)
 			return -ENOMEM;
-		}
+
 		grp->pins = pins;
 
 		pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL);
-		if (!pinmux) {
-			of_node_put(np);
+		if (!pinmux)
 			return -ENOMEM;
-		}
 
 		for (j = 0; j < grp->npins; j++) {
 			if (of_property_read_u32_index(np, "pins", j, &pin_id)) {
 				dev_err(dev, "Group %s: Read intel pins id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			if (pin_id >= drvdata->pctl_desc.npins) {
 				dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n",
 					grp->name, j, pin_id);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pins[j] = pin_id;
 			if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) {
 				dev_err(dev, "Group %s: Read intel pinmux id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pinmux[j] = pinmux_id;
@@ -764,7 +754,6 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 						pinmux);
 		if (err < 0) {
 			dev_err(dev, "Failed to register group %s\n", grp->name);
-			of_node_put(np);
 			return err;
 		}
 		memset(&group, 0, sizeof(group));

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 13/21] pinctrl: equilibrium: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-equilibrium.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c
index 6e1be38865c3..e727257bb697 100644
--- a/drivers/pinctrl/pinctrl-equilibrium.c
+++ b/drivers/pinctrl/pinctrl-equilibrium.c
@@ -588,14 +588,13 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 		       unsigned int *nr_funcs, funcs_util_ops op)
 {
 	struct device_node *node = dev->of_node;
-	struct device_node *np;
 	struct property *prop;
 	const char *fn_name;
 	unsigned int fid;
 	int i, j;
 
 	i = 0;
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -633,7 +632,6 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 			break;
 
 		default:
-			of_node_put(np);
 			return -EINVAL;
 		}
 		i++;
@@ -706,11 +704,10 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 	struct device_node *node = dev->of_node;
 	unsigned int *pins, *pinmux, pin_id, pinmux_id;
 	struct pingroup group, *grp = &group;
-	struct device_node *np;
 	struct property *prop;
 	int j, err;
 
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -718,42 +715,35 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 		err = of_property_count_u32_elems(np, "pins");
 		if (err < 0) {
 			dev_err(dev, "No pins in the group: %s\n", prop->name);
-			of_node_put(np);
 			return err;
 		}
 		grp->npins = err;
 		grp->name = prop->value;
 		pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL);
-		if (!pins) {
-			of_node_put(np);
+		if (!pins)
 			return -ENOMEM;
-		}
+
 		grp->pins = pins;
 
 		pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL);
-		if (!pinmux) {
-			of_node_put(np);
+		if (!pinmux)
 			return -ENOMEM;
-		}
 
 		for (j = 0; j < grp->npins; j++) {
 			if (of_property_read_u32_index(np, "pins", j, &pin_id)) {
 				dev_err(dev, "Group %s: Read intel pins id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			if (pin_id >= drvdata->pctl_desc.npins) {
 				dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n",
 					grp->name, j, pin_id);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pins[j] = pin_id;
 			if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) {
 				dev_err(dev, "Group %s: Read intel pinmux id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pinmux[j] = pinmux_id;
@@ -764,7 +754,6 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 						pinmux);
 		if (err < 0) {
 			dev_err(dev, "Failed to register group %s\n", grp->name);
-			of_node_put(np);
 			return err;
 		}
 		memset(&group, 0, sizeof(group));

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 13/21] pinctrl: equilibrium: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-equilibrium.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c
index 6e1be38865c3..e727257bb697 100644
--- a/drivers/pinctrl/pinctrl-equilibrium.c
+++ b/drivers/pinctrl/pinctrl-equilibrium.c
@@ -588,14 +588,13 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 		       unsigned int *nr_funcs, funcs_util_ops op)
 {
 	struct device_node *node = dev->of_node;
-	struct device_node *np;
 	struct property *prop;
 	const char *fn_name;
 	unsigned int fid;
 	int i, j;
 
 	i = 0;
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -633,7 +632,6 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs,
 			break;
 
 		default:
-			of_node_put(np);
 			return -EINVAL;
 		}
 		i++;
@@ -706,11 +704,10 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 	struct device_node *node = dev->of_node;
 	unsigned int *pins, *pinmux, pin_id, pinmux_id;
 	struct pingroup group, *grp = &group;
-	struct device_node *np;
 	struct property *prop;
 	int j, err;
 
-	for_each_child_of_node(node, np) {
+	for_each_child_of_node_scoped(node, np) {
 		prop = of_find_property(np, "groups", NULL);
 		if (!prop)
 			continue;
@@ -718,42 +715,35 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 		err = of_property_count_u32_elems(np, "pins");
 		if (err < 0) {
 			dev_err(dev, "No pins in the group: %s\n", prop->name);
-			of_node_put(np);
 			return err;
 		}
 		grp->npins = err;
 		grp->name = prop->value;
 		pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL);
-		if (!pins) {
-			of_node_put(np);
+		if (!pins)
 			return -ENOMEM;
-		}
+
 		grp->pins = pins;
 
 		pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL);
-		if (!pinmux) {
-			of_node_put(np);
+		if (!pinmux)
 			return -ENOMEM;
-		}
 
 		for (j = 0; j < grp->npins; j++) {
 			if (of_property_read_u32_index(np, "pins", j, &pin_id)) {
 				dev_err(dev, "Group %s: Read intel pins id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			if (pin_id >= drvdata->pctl_desc.npins) {
 				dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n",
 					grp->name, j, pin_id);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pins[j] = pin_id;
 			if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) {
 				dev_err(dev, "Group %s: Read intel pinmux id failed\n",
 					grp->name);
-				of_node_put(np);
 				return -EINVAL;
 			}
 			pinmux[j] = pinmux_id;
@@ -764,7 +754,6 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
 						pinmux);
 		if (err < 0) {
 			dev_err(dev, "Failed to register group %s\n", grp->name);
-			of_node_put(np);
 			return err;
 		}
 		memset(&group, 0, sizeof(group));

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 14/21] pinctrl: at91: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-at91-pio4.c |  7 ++-----
 drivers/pinctrl/pinctrl-at91.c      | 17 +++++------------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index a27c01fcbb47..8b01d312305a 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -632,7 +632,6 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				     struct pinctrl_map **map,
 				     unsigned int *num_maps)
 {
-	struct device_node *np;
 	unsigned int reserved_maps;
 	int ret;
 
@@ -648,13 +647,11 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	ret = atmel_pctl_dt_subnode_to_map(pctldev, np_config, map,
 					   &reserved_maps, num_maps);
 	if (ret) {
-		for_each_child_of_node(np_config, np) {
+		for_each_child_of_node_scoped(np_config, np) {
 			ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
-			if (ret < 0) {
-				of_node_put(np);
+			if (ret < 0)
 				break;
-			}
 		}
 	}
 
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 5aa9d5c533c6..cc32db0797e6 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -292,7 +292,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	const struct at91_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -325,7 +325,6 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -1244,7 +1243,6 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
 static int at91_pinctrl_parse_functions(struct device_node *np,
 					struct at91_pinctrl *info, u32 index)
 {
-	struct device_node *child;
 	struct at91_pmx_func *func;
 	struct at91_pin_group *grp;
 	int ret;
@@ -1267,14 +1265,12 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = at91_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -1296,7 +1292,6 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 	int i, j, ngpio_chips_enabled = 0;
 	uint32_t *tmp;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 
 	if (!np)
 		return -ENODEV;
@@ -1349,14 +1344,12 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_device_is_compatible(child, gpio_compat))
 			continue;
 		ret = at91_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return dev_err_probe(dev, ret, "failed to parse function\n");
-		}
 	}
 
 	return 0;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 14/21] pinctrl: at91: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-at91-pio4.c |  7 ++-----
 drivers/pinctrl/pinctrl-at91.c      | 17 +++++------------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index a27c01fcbb47..8b01d312305a 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -632,7 +632,6 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				     struct pinctrl_map **map,
 				     unsigned int *num_maps)
 {
-	struct device_node *np;
 	unsigned int reserved_maps;
 	int ret;
 
@@ -648,13 +647,11 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	ret = atmel_pctl_dt_subnode_to_map(pctldev, np_config, map,
 					   &reserved_maps, num_maps);
 	if (ret) {
-		for_each_child_of_node(np_config, np) {
+		for_each_child_of_node_scoped(np_config, np) {
 			ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
-			if (ret < 0) {
-				of_node_put(np);
+			if (ret < 0)
 				break;
-			}
 		}
 	}
 
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 5aa9d5c533c6..cc32db0797e6 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -292,7 +292,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	const struct at91_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -325,7 +325,6 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -1244,7 +1243,6 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
 static int at91_pinctrl_parse_functions(struct device_node *np,
 					struct at91_pinctrl *info, u32 index)
 {
-	struct device_node *child;
 	struct at91_pmx_func *func;
 	struct at91_pin_group *grp;
 	int ret;
@@ -1267,14 +1265,12 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = at91_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -1296,7 +1292,6 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 	int i, j, ngpio_chips_enabled = 0;
 	uint32_t *tmp;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 
 	if (!np)
 		return -ENODEV;
@@ -1349,14 +1344,12 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_device_is_compatible(child, gpio_compat))
 			continue;
 		ret = at91_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return dev_err_probe(dev, ret, "failed to parse function\n");
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 14/21] pinctrl: at91: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinctrl-at91-pio4.c |  7 ++-----
 drivers/pinctrl/pinctrl-at91.c      | 17 +++++------------
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index a27c01fcbb47..8b01d312305a 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -632,7 +632,6 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				     struct pinctrl_map **map,
 				     unsigned int *num_maps)
 {
-	struct device_node *np;
 	unsigned int reserved_maps;
 	int ret;
 
@@ -648,13 +647,11 @@ static int atmel_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	ret = atmel_pctl_dt_subnode_to_map(pctldev, np_config, map,
 					   &reserved_maps, num_maps);
 	if (ret) {
-		for_each_child_of_node(np_config, np) {
+		for_each_child_of_node_scoped(np_config, np) {
 			ret = atmel_pctl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
-			if (ret < 0) {
-				of_node_put(np);
+			if (ret < 0)
 				break;
-			}
 		}
 	}
 
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 5aa9d5c533c6..cc32db0797e6 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -292,7 +292,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	const struct at91_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i;
 
@@ -325,7 +325,6 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -1244,7 +1243,6 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
 static int at91_pinctrl_parse_functions(struct device_node *np,
 					struct at91_pinctrl *info, u32 index)
 {
-	struct device_node *child;
 	struct at91_pmx_func *func;
 	struct at91_pin_group *grp;
 	int ret;
@@ -1267,14 +1265,12 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = at91_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -1296,7 +1292,6 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 	int i, j, ngpio_chips_enabled = 0;
 	uint32_t *tmp;
 	struct device_node *np = dev->of_node;
-	struct device_node *child;
 
 	if (!np)
 		return -ENODEV;
@@ -1349,14 +1344,12 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 
 	i = 0;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (of_device_is_compatible(child, gpio_compat))
 			continue;
 		ret = at91_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return dev_err_probe(dev, ret, "failed to parse function\n");
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 15/21] pinctrl: s32cc: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nxp/pinctrl-s32cc.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c
index f0cad2c501f7..df3e5d82da4b 100644
--- a/drivers/pinctrl/nxp/pinctrl-s32cc.c
+++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c
@@ -268,28 +268,23 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev,
 			      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
-	int ret = 0;
+	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = s32_dt_group_node_to_map(pctldev, np, map,
 					       &reserved_maps, num_maps,
 					       np_config->name);
 		if (ret < 0) {
-			of_node_put(np);
-			break;
+			pinctrl_utils_free_map(pctldev, *map, *num_maps);
+			return ret;
 		}
 	}
 
-	if (ret)
-		pinctrl_utils_free_map(pctldev, *map, *num_maps);
-
-	return ret;
-
+	return 0;
 }
 
 static const struct pinctrl_ops s32_pctrl_ops = {
@@ -786,7 +781,6 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 					struct s32_pinctrl_soc_info *info,
 					u32 index)
 {
-	struct device_node *child;
 	struct pinfunction *func;
 	struct s32_pin_group *grp;
 	const char **groups;
@@ -810,14 +804,12 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 	if (!groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		groups[i] = child->name;
 		grp = &info->groups[info->grp_index++];
 		ret = s32_pinctrl_parse_groups(child, grp, info);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 		i++;
 	}
 
@@ -831,7 +823,6 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct s32_pinctrl_soc_info *info = ipctl->info;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	struct resource *res;
 	struct regmap *map;
 	void __iomem *base;
@@ -889,7 +880,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	info->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		info->ngroups += of_get_child_count(child);
 
 	info->groups = devm_kcalloc(&pdev->dev, info->ngroups,
@@ -898,12 +889,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = s32_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 15/21] pinctrl: s32cc: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nxp/pinctrl-s32cc.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c
index f0cad2c501f7..df3e5d82da4b 100644
--- a/drivers/pinctrl/nxp/pinctrl-s32cc.c
+++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c
@@ -268,28 +268,23 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev,
 			      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
-	int ret = 0;
+	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = s32_dt_group_node_to_map(pctldev, np, map,
 					       &reserved_maps, num_maps,
 					       np_config->name);
 		if (ret < 0) {
-			of_node_put(np);
-			break;
+			pinctrl_utils_free_map(pctldev, *map, *num_maps);
+			return ret;
 		}
 	}
 
-	if (ret)
-		pinctrl_utils_free_map(pctldev, *map, *num_maps);
-
-	return ret;
-
+	return 0;
 }
 
 static const struct pinctrl_ops s32_pctrl_ops = {
@@ -786,7 +781,6 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 					struct s32_pinctrl_soc_info *info,
 					u32 index)
 {
-	struct device_node *child;
 	struct pinfunction *func;
 	struct s32_pin_group *grp;
 	const char **groups;
@@ -810,14 +804,12 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 	if (!groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		groups[i] = child->name;
 		grp = &info->groups[info->grp_index++];
 		ret = s32_pinctrl_parse_groups(child, grp, info);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 		i++;
 	}
 
@@ -831,7 +823,6 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct s32_pinctrl_soc_info *info = ipctl->info;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	struct resource *res;
 	struct regmap *map;
 	void __iomem *base;
@@ -889,7 +880,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	info->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		info->ngroups += of_get_child_count(child);
 
 	info->groups = devm_kcalloc(&pdev->dev, info->ngroups,
@@ -898,12 +889,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = s32_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 15/21] pinctrl: s32cc: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nxp/pinctrl-s32cc.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c
index f0cad2c501f7..df3e5d82da4b 100644
--- a/drivers/pinctrl/nxp/pinctrl-s32cc.c
+++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c
@@ -268,28 +268,23 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev,
 			      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
-	int ret = 0;
+	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = s32_dt_group_node_to_map(pctldev, np, map,
 					       &reserved_maps, num_maps,
 					       np_config->name);
 		if (ret < 0) {
-			of_node_put(np);
-			break;
+			pinctrl_utils_free_map(pctldev, *map, *num_maps);
+			return ret;
 		}
 	}
 
-	if (ret)
-		pinctrl_utils_free_map(pctldev, *map, *num_maps);
-
-	return ret;
-
+	return 0;
 }
 
 static const struct pinctrl_ops s32_pctrl_ops = {
@@ -786,7 +781,6 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 					struct s32_pinctrl_soc_info *info,
 					u32 index)
 {
-	struct device_node *child;
 	struct pinfunction *func;
 	struct s32_pin_group *grp;
 	const char **groups;
@@ -810,14 +804,12 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
 	if (!groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		groups[i] = child->name;
 		grp = &info->groups[info->grp_index++];
 		ret = s32_pinctrl_parse_groups(child, grp, info);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 		i++;
 	}
 
@@ -831,7 +823,6 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct s32_pinctrl_soc_info *info = ipctl->info;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	struct resource *res;
 	struct regmap *map;
 	void __iomem *base;
@@ -889,7 +880,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	info->ngroups = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		info->ngroups += of_get_child_count(child);
 
 	info->groups = devm_kcalloc(&pdev->dev, info->ngroups,
@@ -898,12 +889,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = s32_pinctrl_parse_functions(child, info, i++);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 16/21] pinctrl: nomadik: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nomadik/pinctrl-abx500.c  | 4 +---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index 80e3ac333136..47f62c89955a 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -811,19 +811,17 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = abx500_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index cb0f0d5a5e45..fa78d5ecc685 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -804,19 +804,17 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 16/21] pinctrl: nomadik: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nomadik/pinctrl-abx500.c  | 4 +---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index 80e3ac333136..47f62c89955a 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -811,19 +811,17 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = abx500_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index cb0f0d5a5e45..fa78d5ecc685 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -804,19 +804,17 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 16/21] pinctrl: nomadik: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/nomadik/pinctrl-abx500.c  | 4 +---
 drivers/pinctrl/nomadik/pinctrl-nomadik.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index 80e3ac333136..47f62c89955a 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -811,19 +811,17 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = abx500_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index cb0f0d5a5e45..fa78d5ecc685 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -804,19 +804,17 @@ static int nmk_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				      unsigned int *num_maps)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
 	*map = NULL;
 	*num_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = nmk_pinctrl_dt_subnode_to_map(pctldev, np, map,
 						    &reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 17/21] pinctrl: mediatek: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 +---
 drivers/pinctrl/mediatek/pinctrl-paris.c      | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index d39afc122516..91edb539925a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -621,7 +621,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -629,12 +628,11 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index b19bc391705e..e12316c42698 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -536,7 +536,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				    struct pinctrl_map **map,
 				    unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -544,13 +543,12 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 						  &reserved_maps,
 						  num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 17/21] pinctrl: mediatek: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 +---
 drivers/pinctrl/mediatek/pinctrl-paris.c      | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index d39afc122516..91edb539925a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -621,7 +621,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -629,12 +628,11 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index b19bc391705e..e12316c42698 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -536,7 +536,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				    struct pinctrl_map **map,
 				    unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -544,13 +543,12 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 						  &reserved_maps,
 						  num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 17/21] pinctrl: mediatek: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 4 +---
 drivers/pinctrl/mediatek/pinctrl-paris.c      | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index d39afc122516..91edb539925a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -621,7 +621,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				 struct device_node *np_config,
 				 struct pinctrl_map **map, unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -629,12 +628,11 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 				&reserved_maps, num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index b19bc391705e..e12316c42698 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -536,7 +536,6 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				    struct pinctrl_map **map,
 				    unsigned *num_maps)
 {
-	struct device_node *np;
 	unsigned reserved_maps;
 	int ret;
 
@@ -544,13 +543,12 @@ static int mtk_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = 0;
 	reserved_maps = 0;
 
-	for_each_child_of_node(np_config, np) {
+	for_each_child_of_node_scoped(np_config, np) {
 		ret = mtk_pctrl_dt_subnode_to_map(pctldev, np, map,
 						  &reserved_maps,
 						  num_maps);
 		if (ret < 0) {
 			pinctrl_utils_free_map(pctldev, *map, *num_maps);
-			of_node_put(np);
 			return ret;
 		}
 	}

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 18/21] pinctrl: freescale: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/freescale/pinctrl-imx.c       | 31 ++++++++-------------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c | 19 ++++++----------
 drivers/pinctrl/freescale/pinctrl-mxs.c       | 24 ++++++++-------------
 3 files changed, 24 insertions(+), 50 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 2d3d80921c0d..cb129325bf24 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -63,7 +63,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct group_desc *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct imx_pin *pin;
 	int map_num = 1;
 	int i, j;
@@ -105,7 +105,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -580,7 +579,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 				       u32 index)
 {
 	struct pinctrl_dev *pctl = ipctl->pctl;
-	struct device_node *child;
 	struct function_desc *func;
 	struct group_desc *grp;
 	const char **group_names;
@@ -605,17 +603,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 	if (!group_names)
 		return -ENOMEM;
 	i = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		group_names[i++] = child->name;
 	func->group_names = group_names;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL);
-		if (!grp) {
-			of_node_put(child);
+		if (!grp)
 			return -ENOMEM;
-		}
 
 		mutex_lock(&ipctl->mutex);
 		radix_tree_insert(&pctl->pin_group_tree,
@@ -635,21 +631,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
  */
 static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np)
 {
-	struct device_node *function_np;
-	struct device_node *pinctrl_np;
-
-	for_each_child_of_node(np, function_np) {
-		if (of_property_read_bool(function_np, "fsl,pins")) {
-			of_node_put(function_np);
+	for_each_child_of_node_scoped(np, function_np) {
+		if (of_property_read_bool(function_np, "fsl,pins"))
 			return true;
-		}
 
-		for_each_child_of_node(function_np, pinctrl_np) {
-			if (of_property_read_bool(pinctrl_np, "fsl,pins")) {
-				of_node_put(pinctrl_np);
-				of_node_put(function_np);
+		for_each_child_of_node_scoped(function_np, pinctrl_np) {
+			if (of_property_read_bool(pinctrl_np, "fsl,pins"))
 				return false;
-			}
 		}
 	}
 
@@ -720,7 +708,7 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	struct regmap_config config = { .name = "gpr" };
 	struct device_node *dev_np = pdev->dev.of_node;
 	struct pinctrl_desc *imx_pinctrl_desc;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct imx_pinctrl *ipctl;
 	struct regmap *gpr;
 	int ret, i;
@@ -765,7 +753,6 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 			}
 
 			ipctl->input_sel_base = of_iomap(np, 0);
-			of_node_put(np);
 			if (!ipctl->input_sel_base) {
 				dev_err(&pdev->dev,
 					"iomuxc input select base address not found\n");
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
index 90c696046b38..409efa1ce8f8 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
@@ -226,7 +226,7 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx1_pinctrl_soc_info *info = ipctl->info;
 	const struct imx1_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i, j;
 
@@ -261,7 +261,6 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -508,7 +507,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 				       struct imx1_pinctrl_soc_info *info,
 				       u32 index)
 {
-	struct device_node *child;
 	struct imx1_pmx_func *func;
 	struct imx1_pin_group *grp;
 	int ret;
@@ -531,14 +529,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = imx1_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -548,7 +544,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 		struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	int ret;
 	u32 nfuncs = 0;
 	u32 ngroups = 0;
@@ -557,7 +552,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!np)
 		return -ENODEV;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		++nfuncs;
 		ngroups += of_get_child_count(child);
 	}
@@ -579,12 +574,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!info->functions || !info->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = imx1_pinctrl_parse_functions(child, info, ifunc++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return -ENOMEM;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c
index e77311f26262..baa1e806688d 100644
--- a/drivers/pinctrl/freescale/pinctrl-mxs.c
+++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
@@ -406,22 +406,22 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct mxs_pinctrl_soc_data *soc = d->soc;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
+	struct device_node *ch;
 	struct mxs_function *f;
 	const char *fn, *fnull = "";
 	int i = 0, idxf = 0, idxg = 0;
 	int ret;
 	u32 val;
 
-	child = of_get_next_child(np, NULL);
-	if (!child) {
+	ch = of_get_next_child(np, NULL);
+	if (!ch) {
 		dev_err(&pdev->dev, "no group is defined\n");
 		return -ENOENT;
 	}
 
 	/* Count total functions and groups */
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		soc->ngroups++;
@@ -450,7 +450,7 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Count groups for each function */
 	fn = fnull;
 	f = &soc->functions[idxf];
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val))
@@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Get groups for each function */
 	idxf = 0;
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val)) {
 			ret = mxs_pinctrl_parse_group(pdev, child,
 						      idxg++, NULL);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 			continue;
 		}
 
@@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 						 f->ngroups,
 						 sizeof(*f->groups),
 						 GFP_KERNEL);
-			if (!f->groups) {
-				of_node_put(child);
+			if (!f->groups)
 				return -ENOMEM;
-			}
 			fn = child->name;
 			i = 0;
 		}
 		ret = mxs_pinctrl_parse_group(pdev, child, idxg++,
 					      &f->groups[i++]);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 18/21] pinctrl: freescale: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/freescale/pinctrl-imx.c       | 31 ++++++++-------------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c | 19 ++++++----------
 drivers/pinctrl/freescale/pinctrl-mxs.c       | 24 ++++++++-------------
 3 files changed, 24 insertions(+), 50 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 2d3d80921c0d..cb129325bf24 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -63,7 +63,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct group_desc *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct imx_pin *pin;
 	int map_num = 1;
 	int i, j;
@@ -105,7 +105,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -580,7 +579,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 				       u32 index)
 {
 	struct pinctrl_dev *pctl = ipctl->pctl;
-	struct device_node *child;
 	struct function_desc *func;
 	struct group_desc *grp;
 	const char **group_names;
@@ -605,17 +603,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 	if (!group_names)
 		return -ENOMEM;
 	i = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		group_names[i++] = child->name;
 	func->group_names = group_names;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL);
-		if (!grp) {
-			of_node_put(child);
+		if (!grp)
 			return -ENOMEM;
-		}
 
 		mutex_lock(&ipctl->mutex);
 		radix_tree_insert(&pctl->pin_group_tree,
@@ -635,21 +631,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
  */
 static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np)
 {
-	struct device_node *function_np;
-	struct device_node *pinctrl_np;
-
-	for_each_child_of_node(np, function_np) {
-		if (of_property_read_bool(function_np, "fsl,pins")) {
-			of_node_put(function_np);
+	for_each_child_of_node_scoped(np, function_np) {
+		if (of_property_read_bool(function_np, "fsl,pins"))
 			return true;
-		}
 
-		for_each_child_of_node(function_np, pinctrl_np) {
-			if (of_property_read_bool(pinctrl_np, "fsl,pins")) {
-				of_node_put(pinctrl_np);
-				of_node_put(function_np);
+		for_each_child_of_node_scoped(function_np, pinctrl_np) {
+			if (of_property_read_bool(pinctrl_np, "fsl,pins"))
 				return false;
-			}
 		}
 	}
 
@@ -720,7 +708,7 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	struct regmap_config config = { .name = "gpr" };
 	struct device_node *dev_np = pdev->dev.of_node;
 	struct pinctrl_desc *imx_pinctrl_desc;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct imx_pinctrl *ipctl;
 	struct regmap *gpr;
 	int ret, i;
@@ -765,7 +753,6 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 			}
 
 			ipctl->input_sel_base = of_iomap(np, 0);
-			of_node_put(np);
 			if (!ipctl->input_sel_base) {
 				dev_err(&pdev->dev,
 					"iomuxc input select base address not found\n");
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
index 90c696046b38..409efa1ce8f8 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
@@ -226,7 +226,7 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx1_pinctrl_soc_info *info = ipctl->info;
 	const struct imx1_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i, j;
 
@@ -261,7 +261,6 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -508,7 +507,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 				       struct imx1_pinctrl_soc_info *info,
 				       u32 index)
 {
-	struct device_node *child;
 	struct imx1_pmx_func *func;
 	struct imx1_pin_group *grp;
 	int ret;
@@ -531,14 +529,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = imx1_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -548,7 +544,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 		struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	int ret;
 	u32 nfuncs = 0;
 	u32 ngroups = 0;
@@ -557,7 +552,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!np)
 		return -ENODEV;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		++nfuncs;
 		ngroups += of_get_child_count(child);
 	}
@@ -579,12 +574,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!info->functions || !info->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = imx1_pinctrl_parse_functions(child, info, ifunc++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return -ENOMEM;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c
index e77311f26262..baa1e806688d 100644
--- a/drivers/pinctrl/freescale/pinctrl-mxs.c
+++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
@@ -406,22 +406,22 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct mxs_pinctrl_soc_data *soc = d->soc;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
+	struct device_node *ch;
 	struct mxs_function *f;
 	const char *fn, *fnull = "";
 	int i = 0, idxf = 0, idxg = 0;
 	int ret;
 	u32 val;
 
-	child = of_get_next_child(np, NULL);
-	if (!child) {
+	ch = of_get_next_child(np, NULL);
+	if (!ch) {
 		dev_err(&pdev->dev, "no group is defined\n");
 		return -ENOENT;
 	}
 
 	/* Count total functions and groups */
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		soc->ngroups++;
@@ -450,7 +450,7 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Count groups for each function */
 	fn = fnull;
 	f = &soc->functions[idxf];
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val))
@@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Get groups for each function */
 	idxf = 0;
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val)) {
 			ret = mxs_pinctrl_parse_group(pdev, child,
 						      idxg++, NULL);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 			continue;
 		}
 
@@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 						 f->ngroups,
 						 sizeof(*f->groups),
 						 GFP_KERNEL);
-			if (!f->groups) {
-				of_node_put(child);
+			if (!f->groups)
 				return -ENOMEM;
-			}
 			fn = child->name;
 			i = 0;
 		}
 		ret = mxs_pinctrl_parse_group(pdev, child, idxg++,
 					      &f->groups[i++]);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 18/21] pinctrl: freescale: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/freescale/pinctrl-imx.c       | 31 ++++++++-------------------
 drivers/pinctrl/freescale/pinctrl-imx1-core.c | 19 ++++++----------
 drivers/pinctrl/freescale/pinctrl-mxs.c       | 24 ++++++++-------------
 3 files changed, 24 insertions(+), 50 deletions(-)

diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 2d3d80921c0d..cb129325bf24 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -63,7 +63,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct group_desc *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	struct imx_pin *pin;
 	int map_num = 1;
 	int i, j;
@@ -105,7 +105,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -580,7 +579,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 				       u32 index)
 {
 	struct pinctrl_dev *pctl = ipctl->pctl;
-	struct device_node *child;
 	struct function_desc *func;
 	struct group_desc *grp;
 	const char **group_names;
@@ -605,17 +603,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 	if (!group_names)
 		return -ENOMEM;
 	i = 0;
-	for_each_child_of_node(np, child)
+	for_each_child_of_node_scoped(np, child)
 		group_names[i++] = child->name;
 	func->group_names = group_names;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL);
-		if (!grp) {
-			of_node_put(child);
+		if (!grp)
 			return -ENOMEM;
-		}
 
 		mutex_lock(&ipctl->mutex);
 		radix_tree_insert(&pctl->pin_group_tree,
@@ -635,21 +631,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
  */
 static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np)
 {
-	struct device_node *function_np;
-	struct device_node *pinctrl_np;
-
-	for_each_child_of_node(np, function_np) {
-		if (of_property_read_bool(function_np, "fsl,pins")) {
-			of_node_put(function_np);
+	for_each_child_of_node_scoped(np, function_np) {
+		if (of_property_read_bool(function_np, "fsl,pins"))
 			return true;
-		}
 
-		for_each_child_of_node(function_np, pinctrl_np) {
-			if (of_property_read_bool(pinctrl_np, "fsl,pins")) {
-				of_node_put(pinctrl_np);
-				of_node_put(function_np);
+		for_each_child_of_node_scoped(function_np, pinctrl_np) {
+			if (of_property_read_bool(pinctrl_np, "fsl,pins"))
 				return false;
-			}
 		}
 	}
 
@@ -720,7 +708,7 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	struct regmap_config config = { .name = "gpr" };
 	struct device_node *dev_np = pdev->dev.of_node;
 	struct pinctrl_desc *imx_pinctrl_desc;
-	struct device_node *np;
+	struct device_node *np __free(device_node) = NULL;
 	struct imx_pinctrl *ipctl;
 	struct regmap *gpr;
 	int ret, i;
@@ -765,7 +753,6 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 			}
 
 			ipctl->input_sel_base = of_iomap(np, 0);
-			of_node_put(np);
 			if (!ipctl->input_sel_base) {
 				dev_err(&pdev->dev,
 					"iomuxc input select base address not found\n");
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
index 90c696046b38..409efa1ce8f8 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
@@ -226,7 +226,7 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	const struct imx1_pinctrl_soc_info *info = ipctl->info;
 	const struct imx1_pin_group *grp;
 	struct pinctrl_map *new_map;
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = NULL;
 	int map_num = 1;
 	int i, j;
 
@@ -261,7 +261,6 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
 	new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;
 	new_map[0].data.mux.function = parent->name;
 	new_map[0].data.mux.group = np->name;
-	of_node_put(parent);
 
 	/* create config map */
 	new_map++;
@@ -508,7 +507,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 				       struct imx1_pinctrl_soc_info *info,
 				       u32 index)
 {
-	struct device_node *child;
 	struct imx1_pmx_func *func;
 	struct imx1_pin_group *grp;
 	int ret;
@@ -531,14 +529,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
 	if (!func->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		func->groups[i] = child->name;
 		grp = &info->groups[grp_index++];
 		ret = imx1_pinctrl_parse_groups(child, grp, info, i++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return ret;
-		}
 	}
 
 	return 0;
@@ -548,7 +544,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 		struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	int ret;
 	u32 nfuncs = 0;
 	u32 ngroups = 0;
@@ -557,7 +552,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!np)
 		return -ENODEV;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		++nfuncs;
 		ngroups += of_get_child_count(child);
 	}
@@ -579,12 +574,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
 	if (!info->functions || !info->groups)
 		return -ENOMEM;
 
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		ret = imx1_pinctrl_parse_functions(child, info, ifunc++);
-		if (ret == -ENOMEM) {
-			of_node_put(child);
+		if (ret == -ENOMEM)
 			return -ENOMEM;
-		}
 	}
 
 	return 0;
diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c
index e77311f26262..baa1e806688d 100644
--- a/drivers/pinctrl/freescale/pinctrl-mxs.c
+++ b/drivers/pinctrl/freescale/pinctrl-mxs.c
@@ -406,22 +406,22 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 {
 	struct mxs_pinctrl_soc_data *soc = d->soc;
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
+	struct device_node *ch;
 	struct mxs_function *f;
 	const char *fn, *fnull = "";
 	int i = 0, idxf = 0, idxg = 0;
 	int ret;
 	u32 val;
 
-	child = of_get_next_child(np, NULL);
-	if (!child) {
+	ch = of_get_next_child(np, NULL);
+	if (!ch) {
 		dev_err(&pdev->dev, "no group is defined\n");
 		return -ENOENT;
 	}
 
 	/* Count total functions and groups */
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		soc->ngroups++;
@@ -450,7 +450,7 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Count groups for each function */
 	fn = fnull;
 	f = &soc->functions[idxf];
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val))
@@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 	/* Get groups for each function */
 	idxf = 0;
 	fn = fnull;
-	for_each_child_of_node(np, child) {
+	for_each_child_of_node_scoped(np, child) {
 		if (is_mxs_gpio(child))
 			continue;
 		if (of_property_read_u32(child, "reg", &val)) {
 			ret = mxs_pinctrl_parse_group(pdev, child,
 						      idxg++, NULL);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 			continue;
 		}
 
@@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 						 f->ngroups,
 						 sizeof(*f->groups),
 						 GFP_KERNEL);
-			if (!f->groups) {
-				of_node_put(child);
+			if (!f->groups)
 				return -ENOMEM;
-			}
 			fn = child->name;
 			i = 0;
 		}
 		ret = mxs_pinctrl_parse_group(pdev, child, idxg++,
 					      &f->groups[i++]);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 	}
 
 	return 0;

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 19/21] pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
index e1285fe2fbc0..59d2ce8462d8 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
@@ -67,7 +67,6 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct bcm63xx_pinctrl *pc;
-	struct device_node *node;
 	int err;
 
 	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
@@ -94,12 +93,11 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 	if (IS_ERR(pc->pctl_dev))
 		return PTR_ERR(pc->pctl_dev);
 
-	for_each_child_of_node(dev->parent->of_node, node) {
+	for_each_child_of_node_scoped(dev->parent->of_node, node) {
 		if (of_match_node(bcm63xx_gpio_of_match, node)) {
 			err = bcm63xx_gpio_probe(dev, node, soc, pc);
 			if (err) {
 				dev_err(dev, "could not add GPIO chip\n");
-				of_node_put(node);
 				return err;
 			}
 		}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 19/21] pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
index e1285fe2fbc0..59d2ce8462d8 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
@@ -67,7 +67,6 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct bcm63xx_pinctrl *pc;
-	struct device_node *node;
 	int err;
 
 	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
@@ -94,12 +93,11 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 	if (IS_ERR(pc->pctl_dev))
 		return PTR_ERR(pc->pctl_dev);
 
-	for_each_child_of_node(dev->parent->of_node, node) {
+	for_each_child_of_node_scoped(dev->parent->of_node, node) {
 		if (of_match_node(bcm63xx_gpio_of_match, node)) {
 			err = bcm63xx_gpio_probe(dev, node, soc, pc);
 			if (err) {
 				dev_err(dev, "could not add GPIO chip\n");
-				of_node_put(node);
 				return err;
 			}
 		}

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 19/21] pinctrl: bcm: bcm63xx: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
index e1285fe2fbc0..59d2ce8462d8 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm63xx.c
@@ -67,7 +67,6 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 {
 	struct device *dev = &pdev->dev;
 	struct bcm63xx_pinctrl *pc;
-	struct device_node *node;
 	int err;
 
 	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
@@ -94,12 +93,11 @@ int bcm63xx_pinctrl_probe(struct platform_device *pdev,
 	if (IS_ERR(pc->pctl_dev))
 		return PTR_ERR(pc->pctl_dev);
 
-	for_each_child_of_node(dev->parent->of_node, node) {
+	for_each_child_of_node_scoped(dev->parent->of_node, node) {
 		if (of_match_node(bcm63xx_gpio_of_match, node)) {
 			err = bcm63xx_gpio_probe(dev, node, soc, pc);
 			if (err) {
 				dev_err(dev, "could not add GPIO chip\n");
-				of_node_put(node);
 				return err;
 			}
 		}

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
index 5bb8fd0d1e41..61fbfddb5938 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
@@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 		return ctx->maps[ip];
 
 	if (ip == ASPEED_IP_GFX) {
-		struct device_node *node;
+		struct device_node *node __free(device_node) = NULL;
 		struct regmap *map;
 
 		node = of_parse_phandle(ctx->dev->of_node,
 					"aspeed,external-nodes", 0);
 		if (node) {
 			map = syscon_node_to_regmap(node);
-			of_node_put(node);
 			if (IS_ERR(map))
 				return map;
 		} else
@@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 	}
 
 	if (ip == ASPEED_IP_LPC) {
-		struct device_node *np;
+		struct device_node *np __free(device_node) = NULL;
 		struct regmap *map;
 
 		np = of_parse_phandle(ctx->dev->of_node,
@@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 				return ERR_PTR(-ENODEV);
 
 			map = syscon_node_to_regmap(np->parent);
-			of_node_put(np);
 			if (IS_ERR(map))
 				return map;
 		} else

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
index 5bb8fd0d1e41..61fbfddb5938 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
@@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 		return ctx->maps[ip];
 
 	if (ip == ASPEED_IP_GFX) {
-		struct device_node *node;
+		struct device_node *node __free(device_node) = NULL;
 		struct regmap *map;
 
 		node = of_parse_phandle(ctx->dev->of_node,
 					"aspeed,external-nodes", 0);
 		if (node) {
 			map = syscon_node_to_regmap(node);
-			of_node_put(node);
 			if (IS_ERR(map))
 				return map;
 		} else
@@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 	}
 
 	if (ip == ASPEED_IP_LPC) {
-		struct device_node *np;
+		struct device_node *np __free(device_node) = NULL;
 		struct regmap *map;
 
 		np = of_parse_phandle(ctx->dev->of_node,
@@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 				return ERR_PTR(-ENODEV);
 
 			map = syscon_node_to_regmap(np->parent);
-			of_node_put(np);
 			if (IS_ERR(map))
 				return map;
 		} else

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
index 5bb8fd0d1e41..61fbfddb5938 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
@@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 		return ctx->maps[ip];
 
 	if (ip == ASPEED_IP_GFX) {
-		struct device_node *node;
+		struct device_node *node __free(device_node) = NULL;
 		struct regmap *map;
 
 		node = of_parse_phandle(ctx->dev->of_node,
 					"aspeed,external-nodes", 0);
 		if (node) {
 			map = syscon_node_to_regmap(node);
-			of_node_put(node);
 			if (IS_ERR(map))
 				return map;
 		} else
@@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 	}
 
 	if (ip == ASPEED_IP_LPC) {
-		struct device_node *np;
+		struct device_node *np __free(device_node) = NULL;
 		struct regmap *map;
 
 		np = of_parse_phandle(ctx->dev->of_node,
@@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 				return ERR_PTR(-ENODEV);
 
 			map = syscon_node_to_regmap(np->parent);
-			of_node_put(np);
 			if (IS_ERR(map))
 				return map;
 		} else

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 21/21] pinctrl: pinconf-generic: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinconf-generic.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 80de389199bd..a499b8af5c1f 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -382,7 +382,6 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 		unsigned int *num_maps, enum pinctrl_map_type type)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -394,13 +393,11 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto exit;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
 					&reserved_maps, num_maps, type);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto exit;
-		}
 	}
 	return 0;
 

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 21/21] pinctrl: pinconf-generic: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinconf-generic.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 80de389199bd..a499b8af5c1f 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -382,7 +382,6 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 		unsigned int *num_maps, enum pinctrl_map_type type)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -394,13 +393,11 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto exit;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
 					&reserved_maps, num_maps, type);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto exit;
-		}
 	}
 	return 0;
 

-- 
2.37.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 21/21] pinctrl: pinconf-generic: Use scope based of_node_put() cleanups
@ 2024-05-01 12:56   ` Peng Fan (OSS)
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan (OSS) @ 2024-05-01 12:56 UTC (permalink / raw)
  To: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pinctrl/pinconf-generic.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 80de389199bd..a499b8af5c1f 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -382,7 +382,6 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 		unsigned int *num_maps, enum pinctrl_map_type type)
 {
 	unsigned int reserved_maps;
-	struct device_node *np;
 	int ret;
 
 	reserved_maps = 0;
@@ -394,13 +393,11 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
 	if (ret < 0)
 		goto exit;
 
-	for_each_available_child_of_node(np_config, np) {
+	for_each_available_child_of_node_scoped(np_config, np) {
 		ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
 					&reserved_maps, num_maps, type);
-		if (ret < 0) {
-			of_node_put(np);
+		if (ret < 0)
 			goto exit;
-		}
 	}
 	return 0;
 

-- 
2.37.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* Re: [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
  2024-05-01 12:56   ` Peng Fan (OSS)
  (?)
@ 2024-05-01 13:30     ` Emil Renner Berthing
  -1 siblings, 0 replies; 103+ messages in thread
From: Emil Renner Berthing @ 2024-05-01 13:30 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use scope based of_node_put() cleanup to simplify code.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>

> ---
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
>  2 files changed, 19 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> index 6df7a310c7ed..27f99183d994 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  {
>  	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
>  	struct device *dev = sfp->gc.parent;
> -	struct device_node *child;
>  	struct pinctrl_map *map;
>  	const char **pgnames;
>  	const char *grpname;
> @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  	nmaps = 0;
>  	ngroups = 0;
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npinmux = of_property_count_u32_elems(child, "pinmux");
>  		int npins   = of_property_count_u32_elems(child, "pins");
>
>  		if (npinmux > 0 && npins > 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>  		if (npinmux == 0 && npins == 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>
> @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins;
>  		int i;
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  			if (!pinmux) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  			if (ret)
> -				goto put_child;
> +				goto free_map;
>
>  			for (i = 0; i < npins; i++) {
>  				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
> @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = NULL;
> @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  				ret = of_property_read_u32_index(child, "pins", i, &v);
>  				if (ret)
> -					goto put_child;
> +					goto free_map;
>  				pins[i] = v;
>  			}
>  		} else {
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	mutex_unlock(&sfp->mutex);
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> index 9609eb1ecc3d..4ce080caa233 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins = of_property_count_u32_elems(child, "pinmux");
>  		int *pins;
>  		u32 *pinmux;
> @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
>  				np, child);
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  		if (!pins) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  		if (!pinmux) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  		if (ret)
> -			goto put_child;
> +			goto free_map;
>
>  		for (i = 0; i < npins; i++)
>  			pins[i] = jh7110_pinmux_pin(pinmux[i]);
> @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  						pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	*num_maps = nmaps;
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
>
> --
> 2.37.1
>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
@ 2024-05-01 13:30     ` Emil Renner Berthing
  0 siblings, 0 replies; 103+ messages in thread
From: Emil Renner Berthing @ 2024-05-01 13:30 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use scope based of_node_put() cleanup to simplify code.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>

> ---
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
>  2 files changed, 19 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> index 6df7a310c7ed..27f99183d994 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  {
>  	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
>  	struct device *dev = sfp->gc.parent;
> -	struct device_node *child;
>  	struct pinctrl_map *map;
>  	const char **pgnames;
>  	const char *grpname;
> @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  	nmaps = 0;
>  	ngroups = 0;
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npinmux = of_property_count_u32_elems(child, "pinmux");
>  		int npins   = of_property_count_u32_elems(child, "pins");
>
>  		if (npinmux > 0 && npins > 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>  		if (npinmux == 0 && npins == 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>
> @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins;
>  		int i;
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  			if (!pinmux) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  			if (ret)
> -				goto put_child;
> +				goto free_map;
>
>  			for (i = 0; i < npins; i++) {
>  				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
> @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = NULL;
> @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  				ret = of_property_read_u32_index(child, "pins", i, &v);
>  				if (ret)
> -					goto put_child;
> +					goto free_map;
>  				pins[i] = v;
>  			}
>  		} else {
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	mutex_unlock(&sfp->mutex);
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> index 9609eb1ecc3d..4ce080caa233 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins = of_property_count_u32_elems(child, "pinmux");
>  		int *pins;
>  		u32 *pinmux;
> @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
>  				np, child);
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  		if (!pins) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  		if (!pinmux) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  		if (ret)
> -			goto put_child;
> +			goto free_map;
>
>  		for (i = 0; i < npins; i++)
>  			pins[i] = jh7110_pinmux_pin(pinmux[i]);
> @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  						pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	*num_maps = nmaps;
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
>
> --
> 2.37.1
>

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups
@ 2024-05-01 13:30     ` Emil Renner Berthing
  0 siblings, 0 replies; 103+ messages in thread
From: Emil Renner Berthing @ 2024-05-01 13:30 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use scope based of_node_put() cleanup to simplify code.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>

> ---
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++-------------
>  drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++--------
>  2 files changed, 19 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> index 6df7a310c7ed..27f99183d994 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c
> @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  {
>  	struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev);
>  	struct device *dev = sfp->gc.parent;
> -	struct device_node *child;
>  	struct pinctrl_map *map;
>  	const char **pgnames;
>  	const char *grpname;
> @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  	nmaps = 0;
>  	ngroups = 0;
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npinmux = of_property_count_u32_elems(child, "pinmux");
>  		int npins   = of_property_count_u32_elems(child, "pins");
>
>  		if (npinmux > 0 && npins > 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>  		if (npinmux == 0 && npins == 0) {
>  			dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n",
>  				np, child);
> -			of_node_put(child);
>  			return -EINVAL;
>  		}
>
> @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins;
>  		int i;
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  			if (!pinmux) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  			if (ret)
> -				goto put_child;
> +				goto free_map;
>
>  			for (i = 0; i < npins; i++) {
>  				unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]);
> @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  			pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  			if (!pins) {
>  				ret = -ENOMEM;
> -				goto put_child;
> +				goto free_map;
>  			}
>
>  			pinmux = NULL;
> @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>
>  				ret = of_property_read_u32_index(child, "pins", i, &v);
>  				if (ret)
> -					goto put_child;
> +					goto free_map;
>  				pins[i] = v;
>  			}
>  		} else {
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	mutex_unlock(&sfp->mutex);
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
> diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> index 9609eb1ecc3d..4ce080caa233 100644
> --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c
> @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	nmaps = 0;
>  	ngroups = 0;
>  	mutex_lock(&sfp->mutex);
> -	for_each_available_child_of_node(np, child) {
> +	for_each_available_child_of_node_scoped(np, child) {
>  		int npins = of_property_count_u32_elems(child, "pinmux");
>  		int *pins;
>  		u32 *pinmux;
> @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				"invalid pinctrl group %pOFn.%pOFn: pinmux not set\n",
>  				np, child);
>  			ret = -EINVAL;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child);
>  		if (!grpname) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pgnames[ngroups++] = grpname;
> @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
>  		if (!pins) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL);
>  		if (!pinmux) {
>  			ret = -ENOMEM;
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = of_property_read_u32_array(child, "pinmux", pinmux, npins);
>  		if (ret)
> -			goto put_child;
> +			goto free_map;
>
>  		for (i = 0; i < npins; i++)
>  			pins[i] = jh7110_pinmux_pin(pinmux[i]);
> @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  						pins, npins, pinmux);
>  		if (ret < 0) {
>  			dev_err(dev, "error adding group %s: %d\n", grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		ret = pinconf_generic_parse_dt_config(child, pctldev,
> @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  		if (ret) {
>  			dev_err(dev, "error parsing pin config of group %s: %d\n",
>  				grpname, ret);
> -			goto put_child;
> +			goto free_map;
>  		}
>
>  		/* don't create a map if there are no pinconf settings */
> @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	*num_maps = nmaps;
>  	return 0;
>
> -put_child:
> -	of_node_put(child);
>  free_map:
>  	pinctrl_utils_free_map(pctldev, map, nmaps);
>  	mutex_unlock(&sfp->mutex);
>
> --
> 2.37.1
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
  2024-05-01 12:55   ` Peng Fan (OSS)
  (?)
@ 2024-05-01 13:32     ` Dan Carpenter
  -1 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 13:32 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
>  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
>  	if (ret) {
>  		dev_err(dev, "Failed to register pinctrl\n");
> -		goto exit_out;
> +		return ret;
>  	}
>  
>  	platform_set_drvdata(pdev, iod);
>  
>  	return pinctrl_enable(iod->pctl);
> -
> -exit_out:
> -	of_node_put(np);
> -	return ret;
>  }

This will call of_node_put() on the success path so it's a behavior
change.  The original code is buggy, it's supposed to call of_node_put()
on the success path here or in ti_iodelay_remove().

If it's supposed to call of_node_put() here, then fine, this is bugfix
but if it's supposed to call it in ti_iodelay_remove() then we need to
save the pointer somewhere using no_free_ptr().  Probably saving ->np
is the safest choice?

The original code is already a little bit buggy because it doesn't
check for pinctrl_enable() errors and cleanup.


diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..f40a1476e4ff 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -156,6 +156,7 @@ struct ti_iodelay_device {
 
 	const struct ti_iodelay_reg_data *reg_data;
 	struct ti_iodelay_reg_values reg_init_conf_values;
+	struct device_node *np;
 };
 
 /**
@@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, iod);
 
-	return pinctrl_enable(iod->pctl);
+	ret = pinctrl_enable(iod->pctl);
+	if (ret)
+		goto exit_out;
+
+	iod->np = no_free_ptr(np);
+	return 0;
 
 exit_out:
 	of_node_put(np);
@@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device *pdev)
 		pinctrl_unregister(iod->pctl);
 
 	ti_iodelay_pinconf_deinit_dev(iod);
+	of_node_put(iod->np);
 
 	/* Expect other allocations to be freed by devm */
 }





^ permalink raw reply related	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-01 13:32     ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 13:32 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
>  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
>  	if (ret) {
>  		dev_err(dev, "Failed to register pinctrl\n");
> -		goto exit_out;
> +		return ret;
>  	}
>  
>  	platform_set_drvdata(pdev, iod);
>  
>  	return pinctrl_enable(iod->pctl);
> -
> -exit_out:
> -	of_node_put(np);
> -	return ret;
>  }

This will call of_node_put() on the success path so it's a behavior
change.  The original code is buggy, it's supposed to call of_node_put()
on the success path here or in ti_iodelay_remove().

If it's supposed to call of_node_put() here, then fine, this is bugfix
but if it's supposed to call it in ti_iodelay_remove() then we need to
save the pointer somewhere using no_free_ptr().  Probably saving ->np
is the safest choice?

The original code is already a little bit buggy because it doesn't
check for pinctrl_enable() errors and cleanup.


diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..f40a1476e4ff 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -156,6 +156,7 @@ struct ti_iodelay_device {
 
 	const struct ti_iodelay_reg_data *reg_data;
 	struct ti_iodelay_reg_values reg_init_conf_values;
+	struct device_node *np;
 };
 
 /**
@@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, iod);
 
-	return pinctrl_enable(iod->pctl);
+	ret = pinctrl_enable(iod->pctl);
+	if (ret)
+		goto exit_out;
+
+	iod->np = no_free_ptr(np);
+	return 0;
 
 exit_out:
 	of_node_put(np);
@@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device *pdev)
 		pinctrl_unregister(iod->pctl);
 
 	ti_iodelay_pinconf_deinit_dev(iod);
+	of_node_put(iod->np);
 
 	/* Expect other allocations to be freed by devm */
 }





_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-01 13:32     ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 13:32 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
>  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
>  	if (ret) {
>  		dev_err(dev, "Failed to register pinctrl\n");
> -		goto exit_out;
> +		return ret;
>  	}
>  
>  	platform_set_drvdata(pdev, iod);
>  
>  	return pinctrl_enable(iod->pctl);
> -
> -exit_out:
> -	of_node_put(np);
> -	return ret;
>  }

This will call of_node_put() on the success path so it's a behavior
change.  The original code is buggy, it's supposed to call of_node_put()
on the success path here or in ti_iodelay_remove().

If it's supposed to call of_node_put() here, then fine, this is bugfix
but if it's supposed to call it in ti_iodelay_remove() then we need to
save the pointer somewhere using no_free_ptr().  Probably saving ->np
is the safest choice?

The original code is already a little bit buggy because it doesn't
check for pinctrl_enable() errors and cleanup.


diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
index 040f2c46a868..f40a1476e4ff 100644
--- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
+++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
@@ -156,6 +156,7 @@ struct ti_iodelay_device {
 
 	const struct ti_iodelay_reg_data *reg_data;
 	struct ti_iodelay_reg_values reg_init_conf_values;
+	struct device_node *np;
 };
 
 /**
@@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, iod);
 
-	return pinctrl_enable(iod->pctl);
+	ret = pinctrl_enable(iod->pctl);
+	if (ret)
+		goto exit_out;
+
+	iod->np = no_free_ptr(np);
+	return 0;
 
 exit_out:
 	of_node_put(np);
@@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device *pdev)
 		pinctrl_unregister(iod->pctl);
 
 	ti_iodelay_pinconf_deinit_dev(iod);
+	of_node_put(iod->np);
 
 	/* Expect other allocations to be freed by devm */
 }





_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
  2024-05-01 12:56   ` Peng Fan (OSS)
  (?)
@ 2024-05-01 16:34     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 103+ messages in thread
From: Krzysztof Kozlowski @ 2024-05-01 16:34 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
>  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
>  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
>  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
>  4 files changed, 14 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> index 85ddf49a5188..9a57b3ceb536 100644
> --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> @@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  		       const struct samsung_retention_data *data)
>  {
>  	struct samsung_retention_ctrl *ctrl;
> -	struct device_node *np;
> +	struct device_node *np __free(device_node) = NULL;
>  	void __iomem *clk_base;
>  
>  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
> @@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  	}
>  
>  	clk_base = of_iomap(np, 0);
> -	of_node_put(np);

I don't think the code as simpler. Previous was very easy to read,
obvious, no error paths.

To me any conversion of such of_node_get immediately followed by
of_node_put is unwelcomed. Easy code is being  converted to complicated one.


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 16:34     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 103+ messages in thread
From: Krzysztof Kozlowski @ 2024-05-01 16:34 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
>  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
>  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
>  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
>  4 files changed, 14 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> index 85ddf49a5188..9a57b3ceb536 100644
> --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> @@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  		       const struct samsung_retention_data *data)
>  {
>  	struct samsung_retention_ctrl *ctrl;
> -	struct device_node *np;
> +	struct device_node *np __free(device_node) = NULL;
>  	void __iomem *clk_base;
>  
>  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
> @@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  	}
>  
>  	clk_base = of_iomap(np, 0);
> -	of_node_put(np);

I don't think the code as simpler. Previous was very easy to read,
obvious, no error paths.

To me any conversion of such of_node_get immediately followed by
of_node_put is unwelcomed. Easy code is being  converted to complicated one.


Best regards,
Krzysztof


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 16:34     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 103+ messages in thread
From: Krzysztof Kozlowski @ 2024-05-01 16:34 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
>  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
>  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
>  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
>  4 files changed, 14 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> index 85ddf49a5188..9a57b3ceb536 100644
> --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> @@ -56,7 +56,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  		       const struct samsung_retention_data *data)
>  {
>  	struct samsung_retention_ctrl *ctrl;
> -	struct device_node *np;
> +	struct device_node *np __free(device_node) = NULL;
>  	void __iomem *clk_base;
>  
>  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
> @@ -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
>  	}
>  
>  	clk_base = of_iomap(np, 0);
> -	of_node_put(np);

I don't think the code as simpler. Previous was very easy to read,
obvious, no error paths.

To me any conversion of such of_node_get immediately followed by
of_node_put is unwelcomed. Easy code is being  converted to complicated one.


Best regards,
Krzysztof


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
  2024-05-01 12:56   ` Peng Fan (OSS)
  (?)
@ 2024-05-01 17:16     ` Dan Carpenter
  -1 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 17:16 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:56:08PM +0800, Peng Fan (OSS) wrote:
> @@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
>  	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
>  
>  	if (!grp->pins || !grp->pin_conf) {
> -		ret = -ENOMEM;
> -		goto out_put_node;
> +		return -ENOMEM;
>  	}

You could delete the curly braces as well.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
@ 2024-05-01 17:16     ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 17:16 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:56:08PM +0800, Peng Fan (OSS) wrote:
> @@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
>  	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
>  
>  	if (!grp->pins || !grp->pin_conf) {
> -		ret = -ENOMEM;
> -		goto out_put_node;
> +		return -ENOMEM;
>  	}

You could delete the curly braces as well.

regards,
dan carpenter



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups
@ 2024-05-01 17:16     ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-01 17:16 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, linux-gpio, linux-kernel,
	linux-tegra, linux-arm-kernel, linux-stm32, linux-samsung-soc,
	linux-renesas-soc, linux-rockchip, linux-riscv, linux-mediatek,
	imx, linux-aspeed, openbmc, Peng Fan

On Wed, May 01, 2024 at 08:56:08PM +0800, Peng Fan (OSS) wrote:
> @@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
>  	grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL);
>  
>  	if (!grp->pins || !grp->pin_conf) {
> -		ret = -ENOMEM;
> -		goto out_put_node;
> +		return -ENOMEM;
>  	}

You could delete the curly braces as well.

regards,
dan carpenter



_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
  2024-05-01 16:34     ` Krzysztof Kozlowski
  (?)
@ 2024-05-01 23:25       ` Peng Fan
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-01 23:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put()
> cleanups
> 
> On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
> >  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
> >  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
> >  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
> >  4 files changed, 14 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > index 85ddf49a5188..9a57b3ceb536 100644
> > --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > @@ -56,7 +56,7 @@ s5pv210_retention_init(struct
> samsung_pinctrl_drv_data *drvdata,
> >  		       const struct samsung_retention_data *data)  {
> >  	struct samsung_retention_ctrl *ctrl;
> > -	struct device_node *np;
> > +	struct device_node *np __free(device_node) = NULL;
> >  	void __iomem *clk_base;
> >
> >  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL); @@
> > -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data
> *drvdata,
> >  	}
> >
> >  	clk_base = of_iomap(np, 0);
> > -	of_node_put(np);
> 
> I don't think the code as simpler. Previous was very easy to read, obvious, no
> error paths.
> 
> To me any conversion of such of_node_get immediately followed by
> of_node_put is unwelcomed. Easy code is being  converted to complicated
> one.

ok. I will drop the changes to code pieces as you commented.

Thanks,
Peng.
> 
> 
> Best regards,
> Krzysztof


^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 23:25       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-01 23:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put()
> cleanups
> 
> On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
> >  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
> >  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
> >  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
> >  4 files changed, 14 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > index 85ddf49a5188..9a57b3ceb536 100644
> > --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > @@ -56,7 +56,7 @@ s5pv210_retention_init(struct
> samsung_pinctrl_drv_data *drvdata,
> >  		       const struct samsung_retention_data *data)  {
> >  	struct samsung_retention_ctrl *ctrl;
> > -	struct device_node *np;
> > +	struct device_node *np __free(device_node) = NULL;
> >  	void __iomem *clk_base;
> >
> >  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL); @@
> > -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data
> *drvdata,
> >  	}
> >
> >  	clk_base = of_iomap(np, 0);
> > -	of_node_put(np);
> 
> I don't think the code as simpler. Previous was very easy to read, obvious, no
> error paths.
> 
> To me any conversion of such of_node_get immediately followed by
> of_node_put is unwelcomed. Easy code is being  converted to complicated
> one.

ok. I will drop the changes to code pieces as you commented.

Thanks,
Peng.
> 
> 
> Best regards,
> Krzysztof

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put() cleanups
@ 2024-05-01 23:25       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-01 23:25 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 08/21] pinctrl: samsung: Use scope based of_node_put()
> cleanups
> 
> On 01/05/2024 14:56, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/samsung/pinctrl-exynos-arm.c |  3 +--
> >  drivers/pinctrl/samsung/pinctrl-exynos.c     | 16 ++++------------
> >  drivers/pinctrl/samsung/pinctrl-s3c64xx.c    |  8 ++------
> >  drivers/pinctrl/samsung/pinctrl-samsung.c    | 26 +++++++-------------------
> >  4 files changed, 14 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > index 85ddf49a5188..9a57b3ceb536 100644
> > --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c
> > @@ -56,7 +56,7 @@ s5pv210_retention_init(struct
> samsung_pinctrl_drv_data *drvdata,
> >  		       const struct samsung_retention_data *data)  {
> >  	struct samsung_retention_ctrl *ctrl;
> > -	struct device_node *np;
> > +	struct device_node *np __free(device_node) = NULL;
> >  	void __iomem *clk_base;
> >
> >  	ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL); @@
> > -71,7 +71,6 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data
> *drvdata,
> >  	}
> >
> >  	clk_base = of_iomap(np, 0);
> > -	of_node_put(np);
> 
> I don't think the code as simpler. Previous was very easy to read, obvious, no
> error paths.
> 
> To me any conversion of such of_node_get immediately followed by
> of_node_put is unwelcomed. Easy code is being  converted to complicated
> one.

ok. I will drop the changes to code pieces as you commented.

Thanks,
Peng.
> 
> 
> Best regards,
> Krzysztof

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
  2024-05-01 13:32     ` Dan Carpenter
  (?)
@ 2024-05-02  0:28       ` Peng Fan
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02  0:28 UTC (permalink / raw)
  To: Dan Carpenter, Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

> Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> cleanups
> 
> On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> platform_device *pdev)
> >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> >  	if (ret) {
> >  		dev_err(dev, "Failed to register pinctrl\n");
> > -		goto exit_out;
> > +		return ret;
> >  	}
> >
> >  	platform_set_drvdata(pdev, iod);
> >
> >  	return pinctrl_enable(iod->pctl);
> > -
> > -exit_out:
> > -	of_node_put(np);
> > -	return ret;
> >  }
> 
> This will call of_node_put() on the success path so it's a behavior change.  The
> original code is buggy, it's supposed to call of_node_put() on the success path
> here or in ti_iodelay_remove().
> 
> If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> supposed to call it in ti_iodelay_remove() then we need to save the pointer
> somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> 
> The original code is already a little bit buggy because it doesn't check for
> pinctrl_enable() errors and cleanup.

It was introduced by 
commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
Author: Tony Lindgren <tony@atomide.com>
Date:   Thu Mar 30 09:16:39 2017 -0700

    pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()

of_node_put is expected in probe, not in remove.

Thanks,
Peng.

> 
> 
> diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-
> iodelay.c
> index 040f2c46a868..f40a1476e4ff 100644
> --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> @@ -156,6 +156,7 @@ struct ti_iodelay_device {
> 
>  	const struct ti_iodelay_reg_data *reg_data;
>  	struct ti_iodelay_reg_values reg_init_conf_values;
> +	struct device_node *np;
>  };
> 
>  /**
> @@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device
> *pdev)
> 
>  	platform_set_drvdata(pdev, iod);
> 
> -	return pinctrl_enable(iod->pctl);
> +	ret = pinctrl_enable(iod->pctl);
> +	if (ret)
> +		goto exit_out;
> +
> +	iod->np = no_free_ptr(np);
> +	return 0;
> 
>  exit_out:
>  	of_node_put(np);
> @@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device
> *pdev)
>  		pinctrl_unregister(iod->pctl);
> 
>  	ti_iodelay_pinconf_deinit_dev(iod);
> +	of_node_put(iod->np);
> 
>  	/* Expect other allocations to be freed by devm */  }
> 
> 
> 


^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-02  0:28       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02  0:28 UTC (permalink / raw)
  To: Dan Carpenter, Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

> Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> cleanups
> 
> On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> platform_device *pdev)
> >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> >  	if (ret) {
> >  		dev_err(dev, "Failed to register pinctrl\n");
> > -		goto exit_out;
> > +		return ret;
> >  	}
> >
> >  	platform_set_drvdata(pdev, iod);
> >
> >  	return pinctrl_enable(iod->pctl);
> > -
> > -exit_out:
> > -	of_node_put(np);
> > -	return ret;
> >  }
> 
> This will call of_node_put() on the success path so it's a behavior change.  The
> original code is buggy, it's supposed to call of_node_put() on the success path
> here or in ti_iodelay_remove().
> 
> If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> supposed to call it in ti_iodelay_remove() then we need to save the pointer
> somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> 
> The original code is already a little bit buggy because it doesn't check for
> pinctrl_enable() errors and cleanup.

It was introduced by 
commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
Author: Tony Lindgren <tony@atomide.com>
Date:   Thu Mar 30 09:16:39 2017 -0700

    pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()

of_node_put is expected in probe, not in remove.

Thanks,
Peng.

> 
> 
> diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-
> iodelay.c
> index 040f2c46a868..f40a1476e4ff 100644
> --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> @@ -156,6 +156,7 @@ struct ti_iodelay_device {
> 
>  	const struct ti_iodelay_reg_data *reg_data;
>  	struct ti_iodelay_reg_values reg_init_conf_values;
> +	struct device_node *np;
>  };
> 
>  /**
> @@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device
> *pdev)
> 
>  	platform_set_drvdata(pdev, iod);
> 
> -	return pinctrl_enable(iod->pctl);
> +	ret = pinctrl_enable(iod->pctl);
> +	if (ret)
> +		goto exit_out;
> +
> +	iod->np = no_free_ptr(np);
> +	return 0;
> 
>  exit_out:
>  	of_node_put(np);
> @@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device
> *pdev)
>  		pinctrl_unregister(iod->pctl);
> 
>  	ti_iodelay_pinconf_deinit_dev(iod);
> +	of_node_put(iod->np);
> 
>  	/* Expect other allocations to be freed by devm */  }
> 
> 
> 


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-02  0:28       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02  0:28 UTC (permalink / raw)
  To: Dan Carpenter, Peng Fan (OSS)
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

> Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> cleanups
> 
> On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> platform_device *pdev)
> >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> >  	if (ret) {
> >  		dev_err(dev, "Failed to register pinctrl\n");
> > -		goto exit_out;
> > +		return ret;
> >  	}
> >
> >  	platform_set_drvdata(pdev, iod);
> >
> >  	return pinctrl_enable(iod->pctl);
> > -
> > -exit_out:
> > -	of_node_put(np);
> > -	return ret;
> >  }
> 
> This will call of_node_put() on the success path so it's a behavior change.  The
> original code is buggy, it's supposed to call of_node_put() on the success path
> here or in ti_iodelay_remove().
> 
> If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> supposed to call it in ti_iodelay_remove() then we need to save the pointer
> somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> 
> The original code is already a little bit buggy because it doesn't check for
> pinctrl_enable() errors and cleanup.

It was introduced by 
commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
Author: Tony Lindgren <tony@atomide.com>
Date:   Thu Mar 30 09:16:39 2017 -0700

    pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()

of_node_put is expected in probe, not in remove.

Thanks,
Peng.

> 
> 
> diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-
> iodelay.c
> index 040f2c46a868..f40a1476e4ff 100644
> --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c
> @@ -156,6 +156,7 @@ struct ti_iodelay_device {
> 
>  	const struct ti_iodelay_reg_data *reg_data;
>  	struct ti_iodelay_reg_values reg_init_conf_values;
> +	struct device_node *np;
>  };
> 
>  /**
> @@ -884,7 +885,12 @@ static int ti_iodelay_probe(struct platform_device
> *pdev)
> 
>  	platform_set_drvdata(pdev, iod);
> 
> -	return pinctrl_enable(iod->pctl);
> +	ret = pinctrl_enable(iod->pctl);
> +	if (ret)
> +		goto exit_out;
> +
> +	iod->np = no_free_ptr(np);
> +	return 0;
> 
>  exit_out:
>  	of_node_put(np);
> @@ -903,6 +909,7 @@ static void ti_iodelay_remove(struct platform_device
> *pdev)
>  		pinctrl_unregister(iod->pctl);
> 
>  	ti_iodelay_pinconf_deinit_dev(iod);
> +	of_node_put(iod->np);
> 
>  	/* Expect other allocations to be freed by devm */  }
> 
> 
> 


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
  2024-05-01 12:56   ` Peng Fan (OSS)
  (?)
  (?)
@ 2024-05-02  0:53     ` Andrew Jeffery
  -1 siblings, 0 replies; 103+ messages in thread
From: Andrew Jeffery @ 2024-05-02  0:53 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> index 5bb8fd0d1e41..61fbfddb5938 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> @@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  		return ctx->maps[ip];
>  
>  	if (ip == ASPEED_IP_GFX) {
> -		struct device_node *node;
> +		struct device_node *node __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		node = of_parse_phandle(ctx->dev->of_node,
>  					"aspeed,external-nodes", 0);
>  		if (node) {
>  			map = syscon_node_to_regmap(node);
> -			of_node_put(node);
>  			if (IS_ERR(map))
>  				return map;
>  		} else
> @@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  	}
>  
>  	if (ip == ASPEED_IP_LPC) {
> -		struct device_node *np;
> +		struct device_node *np __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		np = of_parse_phandle(ctx->dev->of_node,
> @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  				return ERR_PTR(-ENODEV);
>  
>  			map = syscon_node_to_regmap(np->parent);
> -			of_node_put(np);
>  			if (IS_ERR(map))
>  				return map;

I think I agree with Krzysztof's feedback on the Samsung patch[1], and
that I prefer the existing approach for the Aspeed driver. My reasoning
suggests the existing implementation does the right thing. That said,
the code could be adjusted to use early returns and consistent variable
names, which might make it easier to reason about. I'll consider a
follow-up patch to address that.

Regardless, thanks for taking the time to explore the cleanup.

Andrew

[1]: https://lore.kernel.org/lkml/34193501-5b7b-4ffd-8549-a04c6930d02d@kernel.org/

>  		} else
> 


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-02  0:53     ` Andrew Jeffery
  0 siblings, 0 replies; 103+ messages in thread
From: Andrew Jeffery @ 2024-05-02  0:53 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> index 5bb8fd0d1e41..61fbfddb5938 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> @@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  		return ctx->maps[ip];
>  
>  	if (ip == ASPEED_IP_GFX) {
> -		struct device_node *node;
> +		struct device_node *node __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		node = of_parse_phandle(ctx->dev->of_node,
>  					"aspeed,external-nodes", 0);
>  		if (node) {
>  			map = syscon_node_to_regmap(node);
> -			of_node_put(node);
>  			if (IS_ERR(map))
>  				return map;
>  		} else
> @@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  	}
>  
>  	if (ip == ASPEED_IP_LPC) {
> -		struct device_node *np;
> +		struct device_node *np __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		np = of_parse_phandle(ctx->dev->of_node,
> @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  				return ERR_PTR(-ENODEV);
>  
>  			map = syscon_node_to_regmap(np->parent);
> -			of_node_put(np);
>  			if (IS_ERR(map))
>  				return map;

I think I agree with Krzysztof's feedback on the Samsung patch[1], and
that I prefer the existing approach for the Aspeed driver. My reasoning
suggests the existing implementation does the right thing. That said,
the code could be adjusted to use early returns and consistent variable
names, which might make it easier to reason about. I'll consider a
follow-up patch to address that.

Regardless, thanks for taking the time to explore the cleanup.

Andrew

[1]: https://lore.kernel.org/lkml/34193501-5b7b-4ffd-8549-a04c6930d02d@kernel.org/

>  		} else
> 


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-02  0:53     ` Andrew Jeffery
  0 siblings, 0 replies; 103+ messages in thread
From: Andrew Jeffery @ 2024-05-02  0:53 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> index 5bb8fd0d1e41..61fbfddb5938 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> @@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  		return ctx->maps[ip];
>  
>  	if (ip == ASPEED_IP_GFX) {
> -		struct device_node *node;
> +		struct device_node *node __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		node = of_parse_phandle(ctx->dev->of_node,
>  					"aspeed,external-nodes", 0);
>  		if (node) {
>  			map = syscon_node_to_regmap(node);
> -			of_node_put(node);
>  			if (IS_ERR(map))
>  				return map;
>  		} else
> @@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  	}
>  
>  	if (ip == ASPEED_IP_LPC) {
> -		struct device_node *np;
> +		struct device_node *np __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		np = of_parse_phandle(ctx->dev->of_node,
> @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  				return ERR_PTR(-ENODEV);
>  
>  			map = syscon_node_to_regmap(np->parent);
> -			of_node_put(np);
>  			if (IS_ERR(map))
>  				return map;

I think I agree with Krzysztof's feedback on the Samsung patch[1], and
that I prefer the existing approach for the Aspeed driver. My reasoning
suggests the existing implementation does the right thing. That said,
the code could be adjusted to use early returns and consistent variable
names, which might make it easier to reason about. I'll consider a
follow-up patch to address that.

Regardless, thanks for taking the time to explore the cleanup.

Andrew

[1]: https://lore.kernel.org/lkml/34193501-5b7b-4ffd-8549-a04c6930d02d@kernel.org/

>  		} else
> 


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-02  0:53     ` Andrew Jeffery
  0 siblings, 0 replies; 103+ messages in thread
From: Andrew Jeffery @ 2024-05-02  0:53 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Dong Aisheng, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Joel Stanley, Dan Carpenter
  Cc: imx, Peng Fan, linux-samsung-soc, linux-aspeed, linux-rockchip,
	openbmc, linux-kernel, linux-renesas-soc, linux-gpio,
	linux-mediatek, linux-tegra, linux-riscv, linux-stm32,
	linux-arm-kernel

On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> index 5bb8fd0d1e41..61fbfddb5938 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> @@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  		return ctx->maps[ip];
>  
>  	if (ip == ASPEED_IP_GFX) {
> -		struct device_node *node;
> +		struct device_node *node __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		node = of_parse_phandle(ctx->dev->of_node,
>  					"aspeed,external-nodes", 0);
>  		if (node) {
>  			map = syscon_node_to_regmap(node);
> -			of_node_put(node);
>  			if (IS_ERR(map))
>  				return map;
>  		} else
> @@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  	}
>  
>  	if (ip == ASPEED_IP_LPC) {
> -		struct device_node *np;
> +		struct device_node *np __free(device_node) = NULL;
>  		struct regmap *map;
>  
>  		np = of_parse_phandle(ctx->dev->of_node,
> @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
>  				return ERR_PTR(-ENODEV);
>  
>  			map = syscon_node_to_regmap(np->parent);
> -			of_node_put(np);
>  			if (IS_ERR(map))
>  				return map;

I think I agree with Krzysztof's feedback on the Samsung patch[1], and
that I prefer the existing approach for the Aspeed driver. My reasoning
suggests the existing implementation does the right thing. That said,
the code could be adjusted to use early returns and consistent variable
names, which might make it easier to reason about. I'll consider a
follow-up patch to address that.

Regardless, thanks for taking the time to explore the cleanup.

Andrew

[1]: https://lore.kernel.org/lkml/34193501-5b7b-4ffd-8549-a04c6930d02d@kernel.org/

>  		} else
> 


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
  2024-05-02  0:28       ` Peng Fan
  (?)
@ 2024-05-02  7:05         ` Dan Carpenter
  -1 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-02  7:05 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

On Thu, May 02, 2024 at 12:28:42AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> > cleanups
> > 
> > On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> > platform_device *pdev)
> > >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> > >  	if (ret) {
> > >  		dev_err(dev, "Failed to register pinctrl\n");
> > > -		goto exit_out;
> > > +		return ret;
> > >  	}
> > >
> > >  	platform_set_drvdata(pdev, iod);
> > >
> > >  	return pinctrl_enable(iod->pctl);
> > > -
> > > -exit_out:
> > > -	of_node_put(np);
> > > -	return ret;
> > >  }
> > 
> > This will call of_node_put() on the success path so it's a behavior change.  The
> > original code is buggy, it's supposed to call of_node_put() on the success path
> > here or in ti_iodelay_remove().
> > 
> > If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> > supposed to call it in ti_iodelay_remove() then we need to save the pointer
> > somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> > 
> > The original code is already a little bit buggy because it doesn't check for
> > pinctrl_enable() errors and cleanup.
> 
> It was introduced by 
> commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
> Author: Tony Lindgren <tony@atomide.com>
> Date:   Thu Mar 30 09:16:39 2017 -0700
> 
>     pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()
> 
> of_node_put is expected in probe, not in remove.
> 

Ah, right.  You'll add that for the Fixes tag obviously...

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-02  7:05         ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-02  7:05 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

On Thu, May 02, 2024 at 12:28:42AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> > cleanups
> > 
> > On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> > platform_device *pdev)
> > >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> > >  	if (ret) {
> > >  		dev_err(dev, "Failed to register pinctrl\n");
> > > -		goto exit_out;
> > > +		return ret;
> > >  	}
> > >
> > >  	platform_set_drvdata(pdev, iod);
> > >
> > >  	return pinctrl_enable(iod->pctl);
> > > -
> > > -exit_out:
> > > -	of_node_put(np);
> > > -	return ret;
> > >  }
> > 
> > This will call of_node_put() on the success path so it's a behavior change.  The
> > original code is buggy, it's supposed to call of_node_put() on the success path
> > here or in ti_iodelay_remove().
> > 
> > If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> > supposed to call it in ti_iodelay_remove() then we need to save the pointer
> > somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> > 
> > The original code is already a little bit buggy because it doesn't check for
> > pinctrl_enable() errors and cleanup.
> 
> It was introduced by 
> commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
> Author: Tony Lindgren <tony@atomide.com>
> Date:   Thu Mar 30 09:16:39 2017 -0700
> 
>     pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()
> 
> of_node_put is expected in probe, not in remove.
> 

Ah, right.  You'll add that for the Fixes tag obviously...

regards,
dan carpenter


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
@ 2024-05-02  7:05         ` Dan Carpenter
  0 siblings, 0 replies; 103+ messages in thread
From: Dan Carpenter @ 2024-05-02  7:05 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc

On Thu, May 02, 2024 at 12:28:42AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 01/21] pinctrl: ti: iodelay: Use scope based of_node_put()
> > cleanups
> > 
> > On Wed, May 01, 2024 at 08:55:59PM +0800, Peng Fan (OSS) wrote:
> > > @@ -879,16 +874,12 @@ static int ti_iodelay_probe(struct
> > platform_device *pdev)
> > >  	ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
> > >  	if (ret) {
> > >  		dev_err(dev, "Failed to register pinctrl\n");
> > > -		goto exit_out;
> > > +		return ret;
> > >  	}
> > >
> > >  	platform_set_drvdata(pdev, iod);
> > >
> > >  	return pinctrl_enable(iod->pctl);
> > > -
> > > -exit_out:
> > > -	of_node_put(np);
> > > -	return ret;
> > >  }
> > 
> > This will call of_node_put() on the success path so it's a behavior change.  The
> > original code is buggy, it's supposed to call of_node_put() on the success path
> > here or in ti_iodelay_remove().
> > 
> > If it's supposed to call of_node_put() here, then fine, this is bugfix but if it's
> > supposed to call it in ti_iodelay_remove() then we need to save the pointer
> > somewhere using no_free_ptr().  Probably saving ->np is the safest choice?
> > 
> > The original code is already a little bit buggy because it doesn't check for
> > pinctrl_enable() errors and cleanup.
> 
> It was introduced by 
> commit 6118714275f0a313ecc296a87ed1af32d9691bed (tag: pinctrl-v4.11-4)
> Author: Tony Lindgren <tony@atomide.com>
> Date:   Thu Mar 30 09:16:39 2017 -0700
> 
>     pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()
> 
> of_node_put is expected in probe, not in remove.
> 

Ah, right.  You'll add that for the Fixes tag obviously...

regards,
dan carpenter


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
  2024-05-01 12:56   ` Peng Fan (OSS)
  (?)
@ 2024-05-02  9:45     ` Damien Le Moal
  -1 siblings, 0 replies; 103+ messages in thread
From: Damien Le Moal @ 2024-05-02  9:45 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 5/1/24 21:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/pinctrl-k210.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
> index b6d1ed9ec9a3..2753e14c3e38 100644
> --- a/drivers/pinctrl/pinctrl-k210.c
> +++ b/drivers/pinctrl/pinctrl-k210.c
> @@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				       unsigned int *num_maps)
>  {
>  	unsigned int reserved_maps;
> -	struct device_node *np;
>  	int ret;
>  
>  	reserved_maps = 0;
> @@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	if (ret < 0)
>  		goto err;
>  
> -	for_each_available_child_of_node(np_config, np) {
> +	for_each_available_child_of_node_scoped(np_config, np) {
>  		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
>  						     &reserved_maps, num_maps);
> -		if (ret < 0) {
> -			of_node_put(np);

Personally, I am really not a fan of things that hide code like that scoped
thing... If I want a language that hides code, I would be doing C++ :)
That said, I am not opposed to this so I will let Linus (Walleij) decide.

Also, I think that "for_each_available_child_of_node" is a bad name... It really
should be something like for_each_available_child_of_node_get() to make it clear
that a of_node_put() is needed.

> +		if (ret < 0)
>  			goto err;
> -		}
>  	}
>  	return 0;
>  
> 

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
@ 2024-05-02  9:45     ` Damien Le Moal
  0 siblings, 0 replies; 103+ messages in thread
From: Damien Le Moal @ 2024-05-02  9:45 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 5/1/24 21:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/pinctrl-k210.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
> index b6d1ed9ec9a3..2753e14c3e38 100644
> --- a/drivers/pinctrl/pinctrl-k210.c
> +++ b/drivers/pinctrl/pinctrl-k210.c
> @@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				       unsigned int *num_maps)
>  {
>  	unsigned int reserved_maps;
> -	struct device_node *np;
>  	int ret;
>  
>  	reserved_maps = 0;
> @@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	if (ret < 0)
>  		goto err;
>  
> -	for_each_available_child_of_node(np_config, np) {
> +	for_each_available_child_of_node_scoped(np_config, np) {
>  		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
>  						     &reserved_maps, num_maps);
> -		if (ret < 0) {
> -			of_node_put(np);

Personally, I am really not a fan of things that hide code like that scoped
thing... If I want a language that hides code, I would be doing C++ :)
That said, I am not opposed to this so I will let Linus (Walleij) decide.

Also, I think that "for_each_available_child_of_node" is a bad name... It really
should be something like for_each_available_child_of_node_get() to make it clear
that a of_node_put() is needed.

> +		if (ret < 0)
>  			goto err;
> -		}
>  	}
>  	return 0;
>  
> 

-- 
Damien Le Moal
Western Digital Research


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups
@ 2024-05-02  9:45     ` Damien Le Moal
  0 siblings, 0 replies; 103+ messages in thread
From: Damien Le Moal @ 2024-05-02  9:45 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc, Peng Fan

On 5/1/24 21:56, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Use scope based of_node_put() cleanup to simplify code.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/pinctrl/pinctrl-k210.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c
> index b6d1ed9ec9a3..2753e14c3e38 100644
> --- a/drivers/pinctrl/pinctrl-k210.c
> +++ b/drivers/pinctrl/pinctrl-k210.c
> @@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				       unsigned int *num_maps)
>  {
>  	unsigned int reserved_maps;
> -	struct device_node *np;
>  	int ret;
>  
>  	reserved_maps = 0;
> @@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	if (ret < 0)
>  		goto err;
>  
> -	for_each_available_child_of_node(np_config, np) {
> +	for_each_available_child_of_node_scoped(np_config, np) {
>  		ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map,
>  						     &reserved_maps, num_maps);
> -		if (ret < 0) {
> -			of_node_put(np);

Personally, I am really not a fan of things that hide code like that scoped
thing... If I want a language that hides code, I would be doing C++ :)
That said, I am not opposed to this so I will let Linus (Walleij) decide.

Also, I think that "for_each_available_child_of_node" is a bad name... It really
should be something like for_each_available_child_of_node_get() to make it clear
that a of_node_put() is needed.

> +		if (ret < 0)
>  			goto err;
> -		}
>  	}
>  	return 0;
>  
> 

-- 
Damien Le Moal
Western Digital Research


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
  2024-05-02  0:53     ` Andrew Jeffery
  (?)
@ 2024-05-02 11:52       ` Peng Fan
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02 11:52 UTC (permalink / raw)
  To: Andrew Jeffery, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based
> of_node_put() cleanups
>
> On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > index 5bb8fd0d1e41..61fbfddb5938 100644
> > --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > @@ -2629,14 +2629,13 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >             return ctx->maps[ip];
> >
> >     if (ip == ASPEED_IP_GFX) {
> > -           struct device_node *node;
> > +           struct device_node *node __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             node = of_parse_phandle(ctx->dev->of_node,
> >                                     "aspeed,external-nodes", 0);
> >             if (node) {
> >                     map = syscon_node_to_regmap(node);
> > -                   of_node_put(node);
> >                     if (IS_ERR(map))
> >                             return map;
> >             } else
> > @@ -2648,7 +2647,7 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >     }
> >
> >     if (ip == ASPEED_IP_LPC) {
> > -           struct device_node *np;
> > +           struct device_node *np __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             np = of_parse_phandle(ctx->dev->of_node,
> > @@ -2660,7 +2659,6 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >                             return ERR_PTR(-ENODEV);
> >
> >                     map = syscon_node_to_regmap(np->parent);
> > -                   of_node_put(np);
> >                     if (IS_ERR(map))
> >                             return map;
>
> I think I agree with Krzysztof's feedback on the Samsung patch[1], and that I
> prefer the existing approach for the Aspeed driver. My reasoning suggests the
> existing implementation does the right thing. That said, the code could be
> adjusted to use early returns and consistent variable names, which might
> make it easier to reason about.

No problem, let's keep the code as it is.

Thanks,
Peng

I'll consider a follow-up patch to address that.
>
> Regardless, thanks for taking the time to explore the cleanup.
>
> Andrew
>
> [1]:
> https://lore.ke/
> rnel.org%2Flkml%2F34193501-5b7b-4ffd-8549-
> a04c6930d02d%40kernel.org%2F&data=05%7C02%7Cpeng.fan%40nxp.com
> %7C44ef77e479264eccd73f08dc6a4263c6%7C686ea1d3bc2b4c6fa92cd99c5
> c301635%7C0%7C0%7C638502080600849943%7CUnknown%7CTWFpbGZs
> b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn
> 0%3D%7C0%7C%7C%7C&sdata=tuUu1IeqM5sQjqiN1fwzPAbSoZw%2FUNEd2
> u%2BzpaBhJ4M%3D&reserved=0
>
> >             } else
> >


^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-02 11:52       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02 11:52 UTC (permalink / raw)
  To: Andrew Jeffery, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based
> of_node_put() cleanups
>
> On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > index 5bb8fd0d1e41..61fbfddb5938 100644
> > --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > @@ -2629,14 +2629,13 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >             return ctx->maps[ip];
> >
> >     if (ip == ASPEED_IP_GFX) {
> > -           struct device_node *node;
> > +           struct device_node *node __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             node = of_parse_phandle(ctx->dev->of_node,
> >                                     "aspeed,external-nodes", 0);
> >             if (node) {
> >                     map = syscon_node_to_regmap(node);
> > -                   of_node_put(node);
> >                     if (IS_ERR(map))
> >                             return map;
> >             } else
> > @@ -2648,7 +2647,7 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >     }
> >
> >     if (ip == ASPEED_IP_LPC) {
> > -           struct device_node *np;
> > +           struct device_node *np __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             np = of_parse_phandle(ctx->dev->of_node,
> > @@ -2660,7 +2659,6 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >                             return ERR_PTR(-ENODEV);
> >
> >                     map = syscon_node_to_regmap(np->parent);
> > -                   of_node_put(np);
> >                     if (IS_ERR(map))
> >                             return map;
>
> I think I agree with Krzysztof's feedback on the Samsung patch[1], and that I
> prefer the existing approach for the Aspeed driver. My reasoning suggests the
> existing implementation does the right thing. That said, the code could be
> adjusted to use early returns and consistent variable names, which might
> make it easier to reason about.

No problem, let's keep the code as it is.

Thanks,
Peng

I'll consider a follow-up patch to address that.
>
> Regardless, thanks for taking the time to explore the cleanup.
>
> Andrew
>
> [1]:
> https://lore.ke/
> rnel.org%2Flkml%2F34193501-5b7b-4ffd-8549-
> a04c6930d02d%40kernel.org%2F&data=05%7C02%7Cpeng.fan%40nxp.com
> %7C44ef77e479264eccd73f08dc6a4263c6%7C686ea1d3bc2b4c6fa92cd99c5
> c301635%7C0%7C0%7C638502080600849943%7CUnknown%7CTWFpbGZs
> b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn
> 0%3D%7C0%7C%7C%7C&sdata=tuUu1IeqM5sQjqiN1fwzPAbSoZw%2FUNEd2
> u%2BzpaBhJ4M%3D&reserved=0
>
> >             } else
> >


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups
@ 2024-05-02 11:52       ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-02 11:52 UTC (permalink / raw)
  To: Andrew Jeffery, Peng Fan (OSS),
	Linus Walleij, Thierry Reding, Jonathan Hunter, Dvorkin Dmitry,
	Wells Lu, Maxime Coquelin, Alexandre Torgue,
	Emil Renner Berthing, Jianlong Huang, Hal Feng, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Viresh Kumar, Shiraz Hashim, soc,
	Krzysztof Kozlowski, Sylwester Nawrocki, Alim Akhtar,
	Geert Uytterhoeven, Patrice Chotard, Heiko Stuebner,
	Damien Le Moal, Ludovic Desroches, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Aisheng Dong, Fabio Estevam,
	Shawn Guo, Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Joel Stanley, Dan Carpenter
  Cc: linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

> Subject: Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based
> of_node_put() cleanups
>
> On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use scope based of_node_put() cleanup to simplify code.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > index 5bb8fd0d1e41..61fbfddb5938 100644
> > --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
> > @@ -2629,14 +2629,13 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >             return ctx->maps[ip];
> >
> >     if (ip == ASPEED_IP_GFX) {
> > -           struct device_node *node;
> > +           struct device_node *node __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             node = of_parse_phandle(ctx->dev->of_node,
> >                                     "aspeed,external-nodes", 0);
> >             if (node) {
> >                     map = syscon_node_to_regmap(node);
> > -                   of_node_put(node);
> >                     if (IS_ERR(map))
> >                             return map;
> >             } else
> > @@ -2648,7 +2647,7 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >     }
> >
> >     if (ip == ASPEED_IP_LPC) {
> > -           struct device_node *np;
> > +           struct device_node *np __free(device_node) = NULL;
> >             struct regmap *map;
> >
> >             np = of_parse_phandle(ctx->dev->of_node,
> > @@ -2660,7 +2659,6 @@ static struct regmap
> *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
> >                             return ERR_PTR(-ENODEV);
> >
> >                     map = syscon_node_to_regmap(np->parent);
> > -                   of_node_put(np);
> >                     if (IS_ERR(map))
> >                             return map;
>
> I think I agree with Krzysztof's feedback on the Samsung patch[1], and that I
> prefer the existing approach for the Aspeed driver. My reasoning suggests the
> existing implementation does the right thing. That said, the code could be
> adjusted to use early returns and consistent variable names, which might
> make it easier to reason about.

No problem, let's keep the code as it is.

Thanks,
Peng

I'll consider a follow-up patch to address that.
>
> Regardless, thanks for taking the time to explore the cleanup.
>
> Andrew
>
> [1]:
> https://lore.ke/
> rnel.org%2Flkml%2F34193501-5b7b-4ffd-8549-
> a04c6930d02d%40kernel.org%2F&data=05%7C02%7Cpeng.fan%40nxp.com
> %7C44ef77e479264eccd73f08dc6a4263c6%7C686ea1d3bc2b4c6fa92cd99c5
> c301635%7C0%7C0%7C638502080600849943%7CUnknown%7CTWFpbGZs
> b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn
> 0%3D%7C0%7C%7C%7C&sdata=tuUu1IeqM5sQjqiN1fwzPAbSoZw%2FUNEd2
> u%2BzpaBhJ4M%3D&reserved=0
>
> >             } else
> >


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
  2024-05-01 12:55 ` Peng Fan (OSS)
  (?)
@ 2024-05-03  7:19   ` Linus Walleij
  -1 siblings, 0 replies; 103+ messages in thread
From: Linus Walleij @ 2024-05-03  7:19 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc,
	Peng Fan

Hi Peng,

thanks for doing this! I am very much in favor of using
scoped management of resources where it makes it easier to
do the right thing.

I agree with Krzysztof's comment that we should avoid scoping
in cases where there is a clear path grab/use/release so the
code is easy to read already as it is. Let's drop those.

I saw there was some patch that was even a fix, perhaps I
should pick that one separately for fixes, but probably it is
non-urgent.

I suppose we will just apply v2 after people had some time to
look at it!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-03  7:19   ` Linus Walleij
  0 siblings, 0 replies; 103+ messages in thread
From: Linus Walleij @ 2024-05-03  7:19 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc,
	Peng Fan

Hi Peng,

thanks for doing this! I am very much in favor of using
scoped management of resources where it makes it easier to
do the right thing.

I agree with Krzysztof's comment that we should avoid scoping
in cases where there is a clear path grab/use/release so the
code is easy to read already as it is. Let's drop those.

I saw there was some patch that was even a fix, perhaps I
should pick that one separately for fixes, but probably it is
non-urgent.

I suppose we will just apply v2 after people had some time to
look at it!

Yours,
Linus Walleij

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-03  7:19   ` Linus Walleij
  0 siblings, 0 replies; 103+ messages in thread
From: Linus Walleij @ 2024-05-03  7:19 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Dong Aisheng, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc, Sean Wang,
	Matthias Brugger, AngeloGioacchino Del Regno, Sascha Hauer,
	Andrew Jeffery, Joel Stanley, Dan Carpenter, linux-gpio,
	linux-kernel, linux-tegra, linux-arm-kernel, linux-stm32,
	linux-samsung-soc, linux-renesas-soc, linux-rockchip,
	linux-riscv, linux-mediatek, imx, linux-aspeed, openbmc,
	Peng Fan

Hi Peng,

thanks for doing this! I am very much in favor of using
scoped management of resources where it makes it easier to
do the right thing.

I agree with Krzysztof's comment that we should avoid scoping
in cases where there is a clear path grab/use/release so the
code is easy to read already as it is. Let's drop those.

I saw there was some patch that was even a fix, perhaps I
should pick that one separately for fixes, but probably it is
non-urgent.

I suppose we will just apply v2 after people had some time to
look at it!

Yours,
Linus Walleij

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
  2024-05-03  7:19   ` Linus Walleij
  (?)
@ 2024-05-03 23:11     ` Peng Fan
  -1 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-03 23:11 UTC (permalink / raw)
  To: Linus Walleij, Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter,
	linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

Hi Linus,

> Subject: Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
> 
> Hi Peng,
> 
> thanks for doing this! I am very much in favor of using scoped management
> of resources where it makes it easier to do the right thing.
> 
> I agree with Krzysztof's comment that we should avoid scoping in cases where
> there is a clear path grab/use/release so the code is easy to read already as it
> is. Let's drop those.
Yeah, will drop them in v2.

> 
> I saw there was some patch that was even a fix, perhaps I should pick that
> one separately for fixes, but probably it is non-urgent.

Not urgent, I will add fix tag in v2.

Thanks,
Peng.
> 
> I suppose we will just apply v2 after people had some time to look at it!
> 
> Yours,
> Linus Walleij

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-03 23:11     ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-03 23:11 UTC (permalink / raw)
  To: Linus Walleij, Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter,
	linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

Hi Linus,

> Subject: Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
> 
> Hi Peng,
> 
> thanks for doing this! I am very much in favor of using scoped management
> of resources where it makes it easier to do the right thing.
> 
> I agree with Krzysztof's comment that we should avoid scoping in cases where
> there is a clear path grab/use/release so the code is easy to read already as it
> is. Let's drop those.
Yeah, will drop them in v2.

> 
> I saw there was some patch that was even a fix, perhaps I should pick that
> one separately for fixes, but probably it is non-urgent.

Not urgent, I will add fix tag in v2.

Thanks,
Peng.
> 
> I suppose we will just apply v2 after people had some time to look at it!
> 
> Yours,
> Linus Walleij
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
@ 2024-05-03 23:11     ` Peng Fan
  0 siblings, 0 replies; 103+ messages in thread
From: Peng Fan @ 2024-05-03 23:11 UTC (permalink / raw)
  To: Linus Walleij, Peng Fan (OSS)
  Cc: Thierry Reding, Jonathan Hunter, Dvorkin Dmitry, Wells Lu,
	Maxime Coquelin, Alexandre Torgue, Emil Renner Berthing,
	Jianlong Huang, Hal Feng, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Viresh Kumar, Shiraz Hashim, soc, Krzysztof Kozlowski,
	Sylwester Nawrocki, Alim Akhtar, Geert Uytterhoeven,
	Patrice Chotard, Heiko Stuebner, Damien Le Moal,
	Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Aisheng Dong, Fabio Estevam, Shawn Guo,
	Jacky Bai, Pengutronix Kernel Team, Chester Lin,
	Matthias Brugger, Ghennadi Procopciuc (OSS),
	Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
	Sascha Hauer, Andrew Jeffery, Joel Stanley, Dan Carpenter,
	linux-gpio, linux-kernel, linux-tegra, linux-arm-kernel,
	linux-stm32, linux-samsung-soc, linux-renesas-soc,
	linux-rockchip, linux-riscv, linux-mediatek, imx, linux-aspeed,
	openbmc

Hi Linus,

> Subject: Re: [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups
> 
> Hi Peng,
> 
> thanks for doing this! I am very much in favor of using scoped management
> of resources where it makes it easier to do the right thing.
> 
> I agree with Krzysztof's comment that we should avoid scoping in cases where
> there is a clear path grab/use/release so the code is easy to read already as it
> is. Let's drop those.
Yeah, will drop them in v2.

> 
> I saw there was some patch that was even a fix, perhaps I should pick that
> one separately for fixes, but probably it is non-urgent.

Not urgent, I will add fix tag in v2.

Thanks,
Peng.
> 
> I suppose we will just apply v2 after people had some time to look at it!
> 
> Yours,
> Linus Walleij
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 103+ messages in thread

end of thread, other threads:[~2024-05-03 23:12 UTC | newest]

Thread overview: 103+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01 12:55 [PATCH 00/21] pinctrl: Use scope based of_node_put() cleanups Peng Fan (OSS)
2024-05-01 12:55 ` Peng Fan (OSS)
2024-05-01 12:55 ` Peng Fan (OSS)
2024-05-01 12:55 ` [PATCH 01/21] pinctrl: ti: iodelay: " Peng Fan (OSS)
2024-05-01 12:55   ` Peng Fan (OSS)
2024-05-01 12:55   ` Peng Fan (OSS)
2024-05-01 13:32   ` Dan Carpenter
2024-05-01 13:32     ` Dan Carpenter
2024-05-01 13:32     ` Dan Carpenter
2024-05-02  0:28     ` Peng Fan
2024-05-02  0:28       ` Peng Fan
2024-05-02  0:28       ` Peng Fan
2024-05-02  7:05       ` Dan Carpenter
2024-05-02  7:05         ` Dan Carpenter
2024-05-02  7:05         ` Dan Carpenter
2024-05-01 12:56 ` [PATCH 02/21] pinctrl: tegra: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 03/21] pinctrl: sunplus: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 04/21] pinctrl: stm32: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 05/21] pinctrl: starfive: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 13:30   ` Emil Renner Berthing
2024-05-01 13:30     ` Emil Renner Berthing
2024-05-01 13:30     ` Emil Renner Berthing
2024-05-01 12:56 ` [PATCH 06/21] pinctrl: sprd: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 07/21] pinctrl: spear: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 08/21] pinctrl: samsung: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 16:34   ` Krzysztof Kozlowski
2024-05-01 16:34     ` Krzysztof Kozlowski
2024-05-01 16:34     ` Krzysztof Kozlowski
2024-05-01 23:25     ` Peng Fan
2024-05-01 23:25       ` Peng Fan
2024-05-01 23:25       ` Peng Fan
2024-05-01 12:56 ` [PATCH 09/21] pinctrl: renesas: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 10/21] pinctrl: st: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 17:16   ` Dan Carpenter
2024-05-01 17:16     ` Dan Carpenter
2024-05-01 17:16     ` Dan Carpenter
2024-05-01 12:56 ` [PATCH 11/21] pinctrl: rockchip: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 12/21] pinctrl: k210: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-02  9:45   ` Damien Le Moal
2024-05-02  9:45     ` Damien Le Moal
2024-05-02  9:45     ` Damien Le Moal
2024-05-01 12:56 ` [PATCH 13/21] pinctrl: equilibrium: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 14/21] pinctrl: at91: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 15/21] pinctrl: s32cc: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 16/21] pinctrl: nomadik: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 17/21] pinctrl: mediatek: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 18/21] pinctrl: freescale: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 19/21] pinctrl: bcm: bcm63xx: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56 ` [PATCH 20/21] pinctrl: aspeed: g5: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-02  0:53   ` Andrew Jeffery
2024-05-02  0:53     ` Andrew Jeffery
2024-05-02  0:53     ` Andrew Jeffery
2024-05-02  0:53     ` Andrew Jeffery
2024-05-02 11:52     ` Peng Fan
2024-05-02 11:52       ` Peng Fan
2024-05-02 11:52       ` Peng Fan
2024-05-01 12:56 ` [PATCH 21/21] pinctrl: pinconf-generic: " Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-01 12:56   ` Peng Fan (OSS)
2024-05-03  7:19 ` [PATCH 00/21] pinctrl: " Linus Walleij
2024-05-03  7:19   ` Linus Walleij
2024-05-03  7:19   ` Linus Walleij
2024-05-03 23:11   ` Peng Fan
2024-05-03 23:11     ` Peng Fan
2024-05-03 23:11     ` Peng Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.