linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled()
  2024-09-07  3:09 Li Zetao
@ 2024-09-07  3:03 ` Li Zetao
  0 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:03 UTC (permalink / raw)
  To: mchehab, davem, edumazet, kuba, pabeni, wens, jernej.skrabec,
	samuel, heiko, yisen.zhuang, salil.mehta, hauke, alexandre.torgue,
	joabreu, mcoquelin.stm32, wellslutw, radhey.shyam.pandey,
	michal.simek, hdegoede, ilpo.jarvinen, ruanjinjie, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Sorry to bother you, I made a small mistake when I sent the patch. 
Please ignore the patchset.

在 2024/9/7 11:09, Li Zetao 写道:
> v1 -> v2:
>    1) Patch 5 optimizes the check and adds commit information for easier
>    inspection.
>    2) It is no longer necessary to use clk, so delete the clk member of
>    the spl2sw_common structure.
>    3) Remove patches 11 and 12, they should be sent to wireless-next
>    individually
> 
> v1:
> https://lore.kernel.org/all/20240831021334.1907921-1-lizetao1@huawei.com/
> 
> There are many examples[1][2] of clk resource leakage in LTS. The
> reason is that developers need to maintain the allocation and release
> of clk resources themselves, but this will increase the burden on
> developers. Using the API related to devm_clk_get_*_enable ensures
> that the life cycle of clk is consistent with that of the device,
> reducing the risk of unreleased resources like clk.
> 
> Several other developers are also working on converting to more
> secure interfaces, and this patch set is in principle the same as
> theirs.
> 
> [1]:
> https://lore.kernel.org/all/20240812160128.338041191@linuxfoundation.org/
> [2]:
> https://lore.kernel.org/all/20240812160135.992451065@linuxfoundation.org/
> 
> Li Zetao (10):
>    net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in
>      bcm_sf2_sw_probe()
>    net: ethernet: Convert using devm_clk_get_enabled() in emac_probe()
>    net: ethernet: arc: Convert using devm_clk_get_enabled() in
>      emac_probe()
>    net: ethernet: ethoc: Convert using devm_clk_get_enabled() in
>      ethoc_probe()
>    net: ftgmac100: Convert using devm_clk_get_enabled() in
>      ftgmac100_setup_clk()
>    net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in
>      hisi_femac_drv_probe()
>    net: lantiq_xrx200: Convert using devm_clk_get_enabled() in
>      xrx200_probe()
>    net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled()
>      in dwc_qos_probe()
>    net: ethernet: sunplus: Convert using devm_clk_get_enabled() in
>      spl2sw_probe()
>    net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in
>      axienet_probe()
> 
>   drivers/net/dsa/bcm_sf2.c                     | 28 ++----
>   drivers/net/ethernet/allwinner/sun4i-emac.c   | 13 +--
>   drivers/net/ethernet/arc/emac_rockchip.c      | 34 ++-----
>   drivers/net/ethernet/ethoc.c                  | 18 ++--
>   drivers/net/ethernet/faraday/ftgmac100.c      | 26 +----
>   drivers/net/ethernet/hisilicon/hisi_femac.c   | 17 +---
>   drivers/net/ethernet/lantiq_xrx200.c          | 17 +---
>   .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 98 ++++---------------
>   drivers/net/ethernet/sunplus/spl2sw_define.h  |  1 -
>   drivers/net/ethernet/sunplus/spl2sw_driver.c  | 25 ++---
>   .../net/ethernet/xilinx/xilinx_axienet_main.c | 15 +--
>   11 files changed, 62 insertions(+), 230 deletions(-)
> 

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

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

* [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled()
@ 2024-09-07  3:09 Li Zetao
  2024-09-07  3:03 ` Li Zetao
  0 siblings, 1 reply; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:09 UTC (permalink / raw)
  To: mchehab, davem, edumazet, kuba, pabeni, wens, jernej.skrabec,
	samuel, heiko, yisen.zhuang, salil.mehta, hauke, alexandre.torgue,
	joabreu, mcoquelin.stm32, wellslutw, radhey.shyam.pandey,
	michal.simek, hdegoede, ilpo.jarvinen, lizetao1, ruanjinjie,
	hverkuil-cisco, u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

v1 -> v2:
  1) Patch 5 optimizes the check and adds commit information for easier
  inspection.
  2) It is no longer necessary to use clk, so delete the clk member of
  the spl2sw_common structure.
  3) Remove patches 11 and 12, they should be sent to wireless-next
  individually

v1:
https://lore.kernel.org/all/20240831021334.1907921-1-lizetao1@huawei.com/

There are many examples[1][2] of clk resource leakage in LTS. The
reason is that developers need to maintain the allocation and release
of clk resources themselves, but this will increase the burden on
developers. Using the API related to devm_clk_get_*_enable ensures
that the life cycle of clk is consistent with that of the device,
reducing the risk of unreleased resources like clk.

Several other developers are also working on converting to more
secure interfaces, and this patch set is in principle the same as
theirs.

[1]:
https://lore.kernel.org/all/20240812160128.338041191@linuxfoundation.org/
[2]:
https://lore.kernel.org/all/20240812160135.992451065@linuxfoundation.org/

Li Zetao (10):
  net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in
    bcm_sf2_sw_probe()
  net: ethernet: Convert using devm_clk_get_enabled() in emac_probe()
  net: ethernet: arc: Convert using devm_clk_get_enabled() in
    emac_probe()
  net: ethernet: ethoc: Convert using devm_clk_get_enabled() in
    ethoc_probe()
  net: ftgmac100: Convert using devm_clk_get_enabled() in
    ftgmac100_setup_clk()
  net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in
    hisi_femac_drv_probe()
  net: lantiq_xrx200: Convert using devm_clk_get_enabled() in
    xrx200_probe()
  net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled()
    in dwc_qos_probe()
  net: ethernet: sunplus: Convert using devm_clk_get_enabled() in
    spl2sw_probe()
  net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in
    axienet_probe()

 drivers/net/dsa/bcm_sf2.c                     | 28 ++----
 drivers/net/ethernet/allwinner/sun4i-emac.c   | 13 +--
 drivers/net/ethernet/arc/emac_rockchip.c      | 34 ++-----
 drivers/net/ethernet/ethoc.c                  | 18 ++--
 drivers/net/ethernet/faraday/ftgmac100.c      | 26 +----
 drivers/net/ethernet/hisilicon/hisi_femac.c   | 17 +---
 drivers/net/ethernet/lantiq_xrx200.c          | 17 +---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 98 ++++---------------
 drivers/net/ethernet/sunplus/spl2sw_define.h  |  1 -
 drivers/net/ethernet/sunplus/spl2sw_driver.c  | 25 ++---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 15 +--
 11 files changed, 62 insertions(+), 230 deletions(-)

-- 
2.34.1


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

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

* [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled()
@ 2024-09-07  3:19 Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 01/10] net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Li Zetao
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

v1 -> v2:
  1) Patch 5 optimizes the check and adds commit information for easier
  inspection.
  2) It is no longer necessary to use clk, so delete the clk member of
  the spl2sw_common structure.
  3) Remove patches 11 and 12, they should be sent to wireless-next
  individually

v1:
https://lore.kernel.org/all/20240831021334.1907921-1-lizetao1@huawei.com/

There are many examples[1][2] of clk resource leakage in LTS. The
reason is that developers need to maintain the allocation and release
of clk resources themselves, but this will increase the burden on
developers. Using the API related to devm_clk_get_*_enable ensures
that the life cycle of clk is consistent with that of the device,
reducing the risk of unreleased resources like clk.

Several other developers are also working on converting to more
secure interfaces, and this patch set is in principle the same as
theirs.

[1]:
https://lore.kernel.org/all/20240812160128.338041191@linuxfoundation.org/
[2]:
https://lore.kernel.org/all/20240812160135.992451065@linuxfoundation.org/

Li Zetao (10):
  net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in
    bcm_sf2_sw_probe()
  net: ethernet: Convert using devm_clk_get_enabled() in emac_probe()
  net: ethernet: arc: Convert using devm_clk_get_enabled() in
    emac_probe()
  net: ethernet: ethoc: Convert using devm_clk_get_enabled() in
    ethoc_probe()
  net: ftgmac100: Convert using devm_clk_get_enabled() in
    ftgmac100_setup_clk()
  net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in
    hisi_femac_drv_probe()
  net: lantiq_xrx200: Convert using devm_clk_get_enabled() in
    xrx200_probe()
  net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled()
    in dwc_qos_probe()
  net: ethernet: sunplus: Convert using devm_clk_get_enabled() in
    spl2sw_probe()
  net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in
    axienet_probe()

 drivers/net/dsa/bcm_sf2.c                     | 28 ++----
 drivers/net/ethernet/allwinner/sun4i-emac.c   | 13 +--
 drivers/net/ethernet/arc/emac_rockchip.c      | 34 ++-----
 drivers/net/ethernet/ethoc.c                  | 18 ++--
 drivers/net/ethernet/faraday/ftgmac100.c      | 26 +----
 drivers/net/ethernet/hisilicon/hisi_femac.c   | 17 +---
 drivers/net/ethernet/lantiq_xrx200.c          | 17 +---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 98 ++++---------------
 drivers/net/ethernet/sunplus/spl2sw_define.h  |  1 -
 drivers/net/ethernet/sunplus/spl2sw_driver.c  | 25 ++---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 15 +--
 11 files changed, 62 insertions(+), 230 deletions(-)

-- 
2.34.1


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

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

* [PATCH net-next v2 01/10] net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in bcm_sf2_sw_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe() Li Zetao
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_optional_enabled() instead of devm_clk_get_optional() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the out_clk_mdiv and out_clk labels, and the original error process can
be returned directly.

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/dsa/bcm_sf2.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 0e663ec0c12a..96c0fdb56601 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1453,28 +1453,18 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 		base++;
 	}
 
-	priv->clk = devm_clk_get_optional(&pdev->dev, "sw_switch");
+	priv->clk = devm_clk_get_optional_enabled(&pdev->dev, "sw_switch");
 	if (IS_ERR(priv->clk))
 		return PTR_ERR(priv->clk);
 
-	ret = clk_prepare_enable(priv->clk);
-	if (ret)
-		return ret;
-
-	priv->clk_mdiv = devm_clk_get_optional(&pdev->dev, "sw_switch_mdiv");
-	if (IS_ERR(priv->clk_mdiv)) {
-		ret = PTR_ERR(priv->clk_mdiv);
-		goto out_clk;
-	}
-
-	ret = clk_prepare_enable(priv->clk_mdiv);
-	if (ret)
-		goto out_clk;
+	priv->clk_mdiv = devm_clk_get_optional_enabled(&pdev->dev, "sw_switch_mdiv");
+	if (IS_ERR(priv->clk_mdiv))
+		return PTR_ERR(priv->clk_mdiv);
 
 	ret = bcm_sf2_sw_rst(priv);
 	if (ret) {
 		pr_err("unable to software reset switch: %d\n", ret);
-		goto out_clk_mdiv;
+		return ret;
 	}
 
 	bcm_sf2_crossbar_setup(priv);
@@ -1484,7 +1474,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 	ret = bcm_sf2_mdio_register(ds);
 	if (ret) {
 		pr_err("failed to register MDIO bus\n");
-		goto out_clk_mdiv;
+		return ret;
 	}
 
 	bcm_sf2_gphy_enable_set(priv->dev->ds, false);
@@ -1551,10 +1541,6 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
 
 out_mdio:
 	bcm_sf2_mdio_unregister(priv);
-out_clk_mdiv:
-	clk_disable_unprepare(priv->clk_mdiv);
-out_clk:
-	clk_disable_unprepare(priv->clk);
 	return ret;
 }
 
@@ -1571,8 +1557,6 @@ static void bcm_sf2_sw_remove(struct platform_device *pdev)
 	dsa_unregister_switch(priv->dev->ds);
 	bcm_sf2_cfp_exit(priv->dev->ds);
 	bcm_sf2_mdio_unregister(priv);
-	clk_disable_unprepare(priv->clk_mdiv);
-	clk_disable_unprepare(priv->clk);
 	if (priv->type == BCM7278_DEVICE_ID)
 		reset_control_assert(priv->rcdev);
 }
-- 
2.34.1


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

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

* [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 01/10] net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  5:34   ` Christophe JAILLET
  2024-09-07  3:19 ` [PATCH net-next v2 03/10] net: ethernet: arc: " Li Zetao
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the out_clk_disable_unprepare label, and the original error process can
changed to the out_dispose_mapping error path.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index d761c08fe5c1..8f42501729b7 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -1005,22 +1005,16 @@ static int emac_probe(struct platform_device *pdev)
 	if (emac_configure_dma(db))
 		netdev_info(ndev, "configure dma failed. disable dma.\n");
 
-	db->clk = devm_clk_get(&pdev->dev, NULL);
+	db->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(db->clk)) {
 		ret = PTR_ERR(db->clk);
 		goto out_dispose_mapping;
 	}
 
-	ret = clk_prepare_enable(db->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
-		goto out_dispose_mapping;
-	}
-
 	ret = sunxi_sram_claim(&pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
-		goto out_clk_disable_unprepare;
+		goto out_dispose_mapping;
 	}
 
 	db->phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -1068,8 +1062,6 @@ static int emac_probe(struct platform_device *pdev)
 
 out_release_sram:
 	sunxi_sram_release(&pdev->dev);
-out_clk_disable_unprepare:
-	clk_disable_unprepare(db->clk);
 out_dispose_mapping:
 	irq_dispose_mapping(ndev->irq);
 	dma_release_channel(db->rx_chan);
@@ -1095,7 +1087,6 @@ static void emac_remove(struct platform_device *pdev)
 
 	unregister_netdev(ndev);
 	sunxi_sram_release(&pdev->dev);
-	clk_disable_unprepare(db->clk);
 	irq_dispose_mapping(ndev->irq);
 	iounmap(db->membase);
 	free_netdev(ndev);
-- 
2.34.1


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

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

* [PATCH net-next v2 03/10] net: ethernet: arc: Convert using devm_clk_get_enabled() in emac_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 01/10] net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 04/10] net: ethernet: ethoc: Convert using devm_clk_get_enabled() in ethoc_probe() Li Zetao
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the out_clk_disable_unprepare label, and the original error process can
changed to the out_dispose_mapping error path.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/arc/emac_rockchip.c | 34 +++++-------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c
index 493d6356c8ca..22b3ebe059d9 100644
--- a/drivers/net/ethernet/arc/emac_rockchip.c
+++ b/drivers/net/ethernet/arc/emac_rockchip.c
@@ -144,7 +144,7 @@ static int emac_rockchip_probe(struct platform_device *pdev)
 		goto out_netdev;
 	}
 
-	priv->refclk = devm_clk_get(dev, "macref");
+	priv->refclk = devm_clk_get_enabled(dev, "macref");
 	if (IS_ERR(priv->refclk)) {
 		dev_err(dev, "failed to retrieve reference clock (%ld)\n",
 			PTR_ERR(priv->refclk));
@@ -152,18 +152,12 @@ static int emac_rockchip_probe(struct platform_device *pdev)
 		goto out_netdev;
 	}
 
-	err = clk_prepare_enable(priv->refclk);
-	if (err) {
-		dev_err(dev, "failed to enable reference clock (%d)\n", err);
-		goto out_netdev;
-	}
-
 	/* Optional regulator for PHY */
 	priv->regulator = devm_regulator_get_optional(dev, "phy");
 	if (IS_ERR(priv->regulator)) {
 		if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) {
 			err = -EPROBE_DEFER;
-			goto out_clk_disable;
+			goto out_netdev;
 		}
 		dev_err(dev, "no regulator found\n");
 		priv->regulator = NULL;
@@ -173,7 +167,7 @@ static int emac_rockchip_probe(struct platform_device *pdev)
 		err = regulator_enable(priv->regulator);
 		if (err) {
 			dev_err(dev, "failed to enable phy-supply (%d)\n", err);
-			goto out_clk_disable;
+			goto out_netdev;
 		}
 	}
 
@@ -200,7 +194,7 @@ static int emac_rockchip_probe(struct platform_device *pdev)
 	}
 
 	if (priv->soc_data->need_div_macclk) {
-		priv->macclk = devm_clk_get(dev, "macclk");
+		priv->macclk = devm_clk_get_enabled(dev, "macclk");
 		if (IS_ERR(priv->macclk)) {
 			dev_err(dev, "failed to retrieve mac clock (%ld)\n",
 				PTR_ERR(priv->macclk));
@@ -208,37 +202,26 @@ static int emac_rockchip_probe(struct platform_device *pdev)
 			goto out_regulator_disable;
 		}
 
-		err = clk_prepare_enable(priv->macclk);
-		if (err) {
-			dev_err(dev, "failed to enable mac clock (%d)\n", err);
-			goto out_regulator_disable;
-		}
-
 		/* RMII TX/RX needs always a rate of 25MHz */
 		err = clk_set_rate(priv->macclk, 25000000);
 		if (err) {
 			dev_err(dev,
 				"failed to change mac clock rate (%d)\n", err);
-			goto out_clk_disable_macclk;
+			goto out_regulator_disable;
 		}
 	}
 
 	err = arc_emac_probe(ndev, interface);
 	if (err) {
 		dev_err(dev, "failed to probe arc emac (%d)\n", err);
-		goto out_clk_disable_macclk;
+		goto out_regulator_disable;
 	}
 
 	return 0;
 
-out_clk_disable_macclk:
-	if (priv->soc_data->need_div_macclk)
-		clk_disable_unprepare(priv->macclk);
 out_regulator_disable:
 	if (priv->regulator)
 		regulator_disable(priv->regulator);
-out_clk_disable:
-	clk_disable_unprepare(priv->refclk);
 out_netdev:
 	free_netdev(ndev);
 	return err;
@@ -251,14 +234,9 @@ static void emac_rockchip_remove(struct platform_device *pdev)
 
 	arc_emac_remove(ndev);
 
-	clk_disable_unprepare(priv->refclk);
-
 	if (priv->regulator)
 		regulator_disable(priv->regulator);
 
-	if (priv->soc_data->need_div_macclk)
-		clk_disable_unprepare(priv->macclk);
-
 	free_netdev(ndev);
 }
 
-- 
2.34.1


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

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

* [PATCH net-next v2 04/10] net: ethernet: ethoc: Convert using devm_clk_get_enabled() in ethoc_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (2 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 03/10] net: ethernet: arc: " Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 05/10] net: ftgmac100: Convert using devm_clk_get_enabled() in ftgmac100_setup_clk() Li Zetao
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the free2 label, and the meaning of the free3 label is not clear, Changing
it to free_mdiobus will make it more understandable.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/ethoc.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index ad41c9019018..1a56e20cb679 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1172,13 +1172,10 @@ static int ethoc_probe(struct platform_device *pdev)
 
 	/* Allow the platform setup code to adjust MII management bus clock. */
 	if (!eth_clkfreq) {
-		struct clk *clk = devm_clk_get(&pdev->dev, NULL);
+		priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 
-		if (!IS_ERR(clk)) {
-			priv->clk = clk;
-			clk_prepare_enable(clk);
-			eth_clkfreq = clk_get_rate(clk);
-		}
+		if (!IS_ERR(priv->clk))
+			eth_clkfreq = clk_get_rate(priv->clk);
 	}
 	if (eth_clkfreq) {
 		u32 clkdiv = MIIMODER_CLKDIV(eth_clkfreq / 2500000 + 1);
@@ -1195,7 +1192,7 @@ static int ethoc_probe(struct platform_device *pdev)
 	priv->mdio = mdiobus_alloc();
 	if (!priv->mdio) {
 		ret = -ENOMEM;
-		goto free2;
+		goto free;
 	}
 
 	priv->mdio->name = "ethoc-mdio";
@@ -1208,7 +1205,7 @@ static int ethoc_probe(struct platform_device *pdev)
 	ret = mdiobus_register(priv->mdio);
 	if (ret) {
 		dev_err(&netdev->dev, "failed to register MDIO bus\n");
-		goto free3;
+		goto free_mdiobus;
 	}
 
 	ret = ethoc_mdio_probe(netdev);
@@ -1240,10 +1237,8 @@ static int ethoc_probe(struct platform_device *pdev)
 	netif_napi_del(&priv->napi);
 error:
 	mdiobus_unregister(priv->mdio);
-free3:
+free_mdiobus:
 	mdiobus_free(priv->mdio);
-free2:
-	clk_disable_unprepare(priv->clk);
 free:
 	free_netdev(netdev);
 out:
@@ -1267,7 +1262,6 @@ static void ethoc_remove(struct platform_device *pdev)
 			mdiobus_unregister(priv->mdio);
 			mdiobus_free(priv->mdio);
 		}
-		clk_disable_unprepare(priv->clk);
 		unregister_netdev(netdev);
 		free_netdev(netdev);
 	}
-- 
2.34.1


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

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

* [PATCH net-next v2 05/10] net: ftgmac100: Convert using devm_clk_get_enabled() in ftgmac100_setup_clk()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (3 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 04/10] net: ethernet: ethoc: Convert using devm_clk_get_enabled() in ethoc_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 06/10] net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in hisi_femac_drv_probe() Li Zetao
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the cleanup_clk label, and the original error process can return directly.

It turns out that checking the return value of clk_prepare_enable is a bit
counter-intuitive. Here use PTR_ERR_OR_ZERO to make it more intuitive.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Optimize return value checking and add commit information for easy
understanding
v1:
https://lore.kernel.org/all/20240831021334.1907921-6-lizetao1@huawei.com/

 drivers/net/ethernet/faraday/ftgmac100.c | 26 +++++-------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index f3cc14cc757d..f2911507d7b8 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1767,13 +1767,10 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 	struct clk *clk;
 	int rc;
 
-	clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
+	clk = devm_clk_get_enabled(priv->dev, NULL /* MACCLK */);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 	priv->clk = clk;
-	rc = clk_prepare_enable(priv->clk);
-	if (rc)
-		return rc;
 
 	/* Aspeed specifies a 100MHz clock is required for up to
 	 * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
@@ -1782,21 +1779,14 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
 	rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
 			  FTGMAC_100MHZ);
 	if (rc)
-		goto cleanup_clk;
+		return rc;
 
 	/* RCLK is for RMII, typically used for NCSI. Optional because it's not
 	 * necessary if it's the AST2400 MAC, or the MAC is configured for
 	 * RGMII, or the controller is not an ASPEED-based controller.
 	 */
-	priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
-	rc = clk_prepare_enable(priv->rclk);
-	if (!rc)
-		return 0;
-
-cleanup_clk:
-	clk_disable_unprepare(priv->clk);
-
-	return rc;
+	priv->rclk = devm_clk_get_optional_enabled(priv->dev, "RCLK");
+	return PTR_ERR_OR_ZERO(priv->rclk);
 }
 
 static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
@@ -2020,16 +2010,13 @@ static int ftgmac100_probe(struct platform_device *pdev)
 	err = register_netdev(netdev);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to register netdev\n");
-		goto err_register_netdev;
+		goto err_phy_connect;
 	}
 
 	netdev_info(netdev, "irq %d, mapped at %p\n", netdev->irq, priv->base);
 
 	return 0;
 
-err_register_netdev:
-	clk_disable_unprepare(priv->rclk);
-	clk_disable_unprepare(priv->clk);
 err_phy_connect:
 	ftgmac100_phy_disconnect(netdev);
 err_ncsi_dev:
@@ -2058,9 +2045,6 @@ static void ftgmac100_remove(struct platform_device *pdev)
 		ncsi_unregister_dev(priv->ndev);
 	unregister_netdev(netdev);
 
-	clk_disable_unprepare(priv->rclk);
-	clk_disable_unprepare(priv->clk);
-
 	/* There's a small chance the reset task will have been re-queued,
 	 * during stop, make sure it's gone before we free the structure.
 	 */
-- 
2.34.1


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

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

* [PATCH net-next v2 06/10] net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in hisi_femac_drv_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (4 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 05/10] net: ftgmac100: Convert using devm_clk_get_enabled() in ftgmac100_setup_clk() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 07/10] net: lantiq_xrx200: Convert using devm_clk_get_enabled() in xrx200_probe() Li Zetao
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the out_disable_clk label, and the original error process can change to
the out_free_netdev error path.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/hisilicon/hisi_femac.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c
index 2406263c9dd3..ffb6f4751d8b 100644
--- a/drivers/net/ethernet/hisilicon/hisi_femac.c
+++ b/drivers/net/ethernet/hisilicon/hisi_femac.c
@@ -797,23 +797,17 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
 		goto out_free_netdev;
 	}
 
-	priv->clk = devm_clk_get(&pdev->dev, NULL);
+	priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		dev_err(dev, "failed to get clk\n");
 		ret = -ENODEV;
 		goto out_free_netdev;
 	}
 
-	ret = clk_prepare_enable(priv->clk);
-	if (ret) {
-		dev_err(dev, "failed to enable clk %d\n", ret);
-		goto out_free_netdev;
-	}
-
 	priv->mac_rst = devm_reset_control_get(dev, "mac");
 	if (IS_ERR(priv->mac_rst)) {
 		ret = PTR_ERR(priv->mac_rst);
-		goto out_disable_clk;
+		goto out_free_netdev;
 	}
 	hisi_femac_core_reset(priv);
 
@@ -826,7 +820,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
 						 priv->phy_reset_delays,
 						 DELAYS_NUM);
 		if (ret)
-			goto out_disable_clk;
+			goto out_free_netdev;
 		hisi_femac_phy_reset(priv);
 	}
 
@@ -834,7 +828,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
 	if (!phy) {
 		dev_err(dev, "connect to PHY failed!\n");
 		ret = -ENODEV;
-		goto out_disable_clk;
+		goto out_free_netdev;
 	}
 
 	phy_attached_print(phy, "phy_id=0x%.8lx, phy_mode=%s\n",
@@ -885,8 +879,6 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
 out_disconnect_phy:
 	netif_napi_del(&priv->napi);
 	phy_disconnect(phy);
-out_disable_clk:
-	clk_disable_unprepare(priv->clk);
 out_free_netdev:
 	free_netdev(ndev);
 
@@ -902,7 +894,6 @@ static void hisi_femac_drv_remove(struct platform_device *pdev)
 	unregister_netdev(ndev);
 
 	phy_disconnect(ndev->phydev);
-	clk_disable_unprepare(priv->clk);
 	free_netdev(ndev);
 }
 
-- 
2.34.1


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

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

* [PATCH net-next v2 07/10] net: lantiq_xrx200: Convert using devm_clk_get_enabled() in xrx200_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (5 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 06/10] net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in hisi_femac_drv_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 08/10] net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled() in dwc_qos_probe() Li Zetao
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the err_unprepare_clk label, and the original error process can change to
the err_uninit_dma error path. Some comments have also been adjusted.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/lantiq_xrx200.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
index 07904a528f21..976748551643 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -589,8 +589,8 @@ static int xrx200_probe(struct platform_device *pdev)
 	if (priv->chan_tx.dma.irq < 0)
 		return -ENOENT;
 
-	/* get the clock */
-	priv->clk = devm_clk_get(dev, NULL);
+	/* get the clock and enable clock gate */
+	priv->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		dev_err(dev, "failed to get clock\n");
 		return PTR_ERR(priv->clk);
@@ -605,11 +605,6 @@ static int xrx200_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
-	/* enable clock gate */
-	err = clk_prepare_enable(priv->clk);
-	if (err)
-		goto err_uninit_dma;
-
 	/* set IPG to 12 */
 	xrx200_pmac_mask(priv, PMAC_RX_IPG_MASK, 0xb, PMAC_RX_IPG);
 
@@ -628,13 +623,10 @@ static int xrx200_probe(struct platform_device *pdev)
 
 	err = register_netdev(net_dev);
 	if (err)
-		goto err_unprepare_clk;
+		goto err_uninit_dma;
 
 	return 0;
 
-err_unprepare_clk:
-	clk_disable_unprepare(priv->clk);
-
 err_uninit_dma:
 	xrx200_hw_cleanup(priv);
 
@@ -654,9 +646,6 @@ static void xrx200_remove(struct platform_device *pdev)
 	/* remove the actual device */
 	unregister_netdev(net_dev);
 
-	/* release the clock */
-	clk_disable_unprepare(priv->clk);
-
 	/* shut down hardware */
 	xrx200_hw_cleanup(priv);
 }
-- 
2.34.1


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

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

* [PATCH net-next v2 08/10] net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled() in dwc_qos_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (6 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 07/10] net: lantiq_xrx200: Convert using devm_clk_get_enabled() in xrx200_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 09/10] net: ethernet: sunplus: Convert using devm_clk_get_enabled() in spl2sw_probe() Li Zetao
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the disable label, and the original error process can return directly.

The tegra_eqos_probe() also has similar modifications.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 .../stmicro/stmmac/dwmac-dwc-qos-eth.c        | 98 ++++---------------
 1 file changed, 17 insertions(+), 81 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index ec924c6c76c6..d6e9a93771f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -123,49 +123,24 @@ static int dwc_qos_probe(struct platform_device *pdev,
 			 struct plat_stmmacenet_data *plat_dat,
 			 struct stmmac_resources *stmmac_res)
 {
-	int err;
-
-	plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk");
+	plat_dat->stmmac_clk = devm_clk_get_enabled(&pdev->dev, "apb_pclk");
 	if (IS_ERR(plat_dat->stmmac_clk)) {
 		dev_err(&pdev->dev, "apb_pclk clock not found.\n");
 		return PTR_ERR(plat_dat->stmmac_clk);
 	}
 
-	err = clk_prepare_enable(plat_dat->stmmac_clk);
-	if (err < 0) {
-		dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n",
-			err);
-		return err;
-	}
-
-	plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk");
+	plat_dat->pclk = devm_clk_get_enabled(&pdev->dev, "phy_ref_clk");
 	if (IS_ERR(plat_dat->pclk)) {
 		dev_err(&pdev->dev, "phy_ref_clk clock not found.\n");
-		err = PTR_ERR(plat_dat->pclk);
-		goto disable;
-	}
-
-	err = clk_prepare_enable(plat_dat->pclk);
-	if (err < 0) {
-		dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n",
-			err);
-		goto disable;
+		return PTR_ERR(plat_dat->pclk);
 	}
 
 	return 0;
-
-disable:
-	clk_disable_unprepare(plat_dat->stmmac_clk);
-	return err;
 }
 
 static void dwc_qos_remove(struct platform_device *pdev)
 {
-	struct net_device *ndev = platform_get_drvdata(pdev);
-	struct stmmac_priv *priv = netdev_priv(ndev);
 
-	clk_disable_unprepare(priv->plat->pclk);
-	clk_disable_unprepare(priv->plat->stmmac_clk);
 }
 
 #define SDMEMCOMPPADCTRL 0x8800
@@ -283,53 +258,27 @@ static int tegra_eqos_probe(struct platform_device *pdev,
 	if (!is_of_node(dev->fwnode))
 		goto bypass_clk_reset_gpio;
 
-	eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus");
-	if (IS_ERR(eqos->clk_master)) {
-		err = PTR_ERR(eqos->clk_master);
-		goto error;
-	}
+	eqos->clk_master = devm_clk_get_enabled(&pdev->dev, "master_bus");
+	if (IS_ERR(eqos->clk_master))
+		return PTR_ERR(eqos->clk_master);
 
-	err = clk_prepare_enable(eqos->clk_master);
-	if (err < 0)
-		goto error;
-
-	eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus");
-	if (IS_ERR(eqos->clk_slave)) {
-		err = PTR_ERR(eqos->clk_slave);
-		goto disable_master;
-	}
+	eqos->clk_slave = devm_clk_get_enabled(&pdev->dev, "slave_bus");
+	if (IS_ERR(eqos->clk_slave))
+		return PTR_ERR(eqos->clk_slave);
 
 	data->stmmac_clk = eqos->clk_slave;
 
-	err = clk_prepare_enable(eqos->clk_slave);
-	if (err < 0)
-		goto disable_master;
-
-	eqos->clk_rx = devm_clk_get(&pdev->dev, "rx");
-	if (IS_ERR(eqos->clk_rx)) {
-		err = PTR_ERR(eqos->clk_rx);
-		goto disable_slave;
-	}
-
-	err = clk_prepare_enable(eqos->clk_rx);
-	if (err < 0)
-		goto disable_slave;
+	eqos->clk_rx = devm_clk_get_enabled(&pdev->dev, "rx");
+	if (IS_ERR(eqos->clk_rx))
+		return PTR_ERR(eqos->clk_rx);
 
-	eqos->clk_tx = devm_clk_get(&pdev->dev, "tx");
-	if (IS_ERR(eqos->clk_tx)) {
-		err = PTR_ERR(eqos->clk_tx);
-		goto disable_rx;
-	}
-
-	err = clk_prepare_enable(eqos->clk_tx);
-	if (err < 0)
-		goto disable_rx;
+	eqos->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
+	if (IS_ERR(eqos->clk_tx))
+		return PTR_ERR(eqos->clk_tx);
 
 	eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH);
-	if (IS_ERR(eqos->reset)) {
-		err = PTR_ERR(eqos->reset);
-		goto disable_tx;
-	}
+	if (IS_ERR(eqos->reset))
+		return PTR_ERR(eqos->reset);
 
 	usleep_range(2000, 4000);
 	gpiod_set_value(eqos->reset, 0);
@@ -370,15 +319,6 @@ static int tegra_eqos_probe(struct platform_device *pdev,
 	reset_control_assert(eqos->rst);
 reset_phy:
 	gpiod_set_value(eqos->reset, 1);
-disable_tx:
-	clk_disable_unprepare(eqos->clk_tx);
-disable_rx:
-	clk_disable_unprepare(eqos->clk_rx);
-disable_slave:
-	clk_disable_unprepare(eqos->clk_slave);
-disable_master:
-	clk_disable_unprepare(eqos->clk_master);
-error:
 	return err;
 }
 
@@ -388,10 +328,6 @@ static void tegra_eqos_remove(struct platform_device *pdev)
 
 	reset_control_assert(eqos->rst);
 	gpiod_set_value(eqos->reset, 1);
-	clk_disable_unprepare(eqos->clk_tx);
-	clk_disable_unprepare(eqos->clk_rx);
-	clk_disable_unprepare(eqos->clk_slave);
-	clk_disable_unprepare(eqos->clk_master);
 }
 
 struct dwc_eth_dwmac_data {
-- 
2.34.1


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

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

* [PATCH net-next v2 09/10] net: ethernet: sunplus: Convert using devm_clk_get_enabled() in spl2sw_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (7 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 08/10] net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled() in dwc_qos_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-07  3:19 ` [PATCH net-next v2 10/10] net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in axienet_probe() Li Zetao
  2024-09-11  3:08 ` [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Jakub Kicinski
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_enabled() instead of devm_clk_get() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path, drop
the out_clk_disable label, and the original error process can return
directly. Some comments have also been adjusted.

After this modification , it is no longer necessary to use clk, so delete
the clk member of the spl2sw_common structure.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Delete the clk member of the spl2sw_common structure
v1:
https://lore.kernel.org/all/20240831021334.1907921-10-lizetao1@huawei.com/

 drivers/net/ethernet/sunplus/spl2sw_define.h |  1 -
 drivers/net/ethernet/sunplus/spl2sw_driver.c | 25 +++++++-------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/sunplus/spl2sw_define.h b/drivers/net/ethernet/sunplus/spl2sw_define.h
index acc6c1228ebc..6318eccc6c4e 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_define.h
+++ b/drivers/net/ethernet/sunplus/spl2sw_define.h
@@ -224,7 +224,6 @@ struct spl2sw_common {
 
 	struct platform_device *pdev;
 	struct reset_control *rstc;
-	struct clk *clk;
 
 	void *desc_base;
 	dma_addr_t desc_dma;
diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index 391a1bc7f446..887da05bc204 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -327,6 +327,7 @@ static int spl2sw_probe(struct platform_device *pdev)
 	struct net_device *ndev;
 	struct spl2sw_mac *mac;
 	u8 mac_addr[ETH_ALEN];
+	struct clk *clk;
 	int irq, i, ret;
 
 	if (platform_get_drvdata(pdev))
@@ -355,12 +356,12 @@ static int spl2sw_probe(struct platform_device *pdev)
 		return ret;
 	irq = ret;
 
-	/* Get clock controller. */
-	comm->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(comm->clk)) {
-		dev_err_probe(&pdev->dev, PTR_ERR(comm->clk),
+	/* Get and enable clock controller. */
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
+	if (IS_ERR(clk)) {
+		dev_err_probe(&pdev->dev, PTR_ERR(clk),
 			      "Failed to retrieve clock controller!\n");
-		return PTR_ERR(comm->clk);
+		return PTR_ERR(clk);
 	}
 
 	/* Get reset controller. */
@@ -371,10 +372,6 @@ static int spl2sw_probe(struct platform_device *pdev)
 		return PTR_ERR(comm->rstc);
 	}
 
-	/* Enable clock. */
-	ret = clk_prepare_enable(comm->clk);
-	if (ret)
-		return ret;
 	udelay(1);
 
 	/* Reset MAC */
@@ -388,7 +385,7 @@ static int spl2sw_probe(struct platform_device *pdev)
 			       dev_name(&pdev->dev), comm);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to request irq #%d!\n", irq);
-		goto out_clk_disable;
+		return ret;
 	}
 
 	/* Initialize TX and RX descriptors. */
@@ -396,7 +393,7 @@ static int spl2sw_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev, "Fail to initialize mac descriptors!\n");
 		spl2sw_descs_free(comm);
-		goto out_clk_disable;
+		return ret;
 	}
 
 	/* Initialize MAC. */
@@ -406,7 +403,7 @@ static int spl2sw_probe(struct platform_device *pdev)
 	ret = spl2sw_mdio_init(comm);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to initialize mdio bus!\n");
-		goto out_clk_disable;
+		return ret;
 	}
 
 	/* Get child node ethernet-ports. */
@@ -506,8 +503,6 @@ static int spl2sw_probe(struct platform_device *pdev)
 out_free_mdio:
 	spl2sw_mdio_remove(comm);
 
-out_clk_disable:
-	clk_disable_unprepare(comm->clk);
 	return ret;
 }
 
@@ -536,8 +531,6 @@ static void spl2sw_remove(struct platform_device *pdev)
 	netif_napi_del(&comm->tx_napi);
 
 	spl2sw_mdio_remove(comm);
-
-	clk_disable_unprepare(comm->clk);
 }
 
 static const struct of_device_id spl2sw_of_match[] = {
-- 
2.34.1


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

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

* [PATCH net-next v2 10/10] net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in axienet_probe()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (8 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 09/10] net: ethernet: sunplus: Convert using devm_clk_get_enabled() in spl2sw_probe() Li Zetao
@ 2024-09-07  3:19 ` Li Zetao
  2024-09-11  3:08 ` [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Jakub Kicinski
  10 siblings, 0 replies; 15+ messages in thread
From: Li Zetao @ 2024-09-07  3:19 UTC (permalink / raw)
  To: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet, kuba,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, lizetao1, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Use devm_clk_get_optional_enabled() instead of devm_clk_get_optional() +
clk_prepare_enable(), which can make the clk consistent with the device
life cycle and reduce the risk of unreleased clk resources. Since the
device framework has automatically released the clk resource, there is
no need to execute clk_disable_unprepare(clk) on the error path.

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
 drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 374dff70ef0d..87c5dcec2325 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -2592,22 +2592,17 @@ static int axienet_probe(struct platform_device *pdev)
 	seqcount_mutex_init(&lp->hw_stats_seqcount, &lp->stats_lock);
 	INIT_DEFERRABLE_WORK(&lp->stats_work, axienet_refresh_stats);
 
-	lp->axi_clk = devm_clk_get_optional(&pdev->dev, "s_axi_lite_clk");
-	if (!lp->axi_clk) {
+	lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev, "s_axi_lite_clk");
+	if (!lp->axi_clk)
 		/* For backward compatibility, if named AXI clock is not present,
 		 * treat the first clock specified as the AXI clock.
 		 */
-		lp->axi_clk = devm_clk_get_optional(&pdev->dev, NULL);
-	}
+		lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+
 	if (IS_ERR(lp->axi_clk)) {
 		ret = PTR_ERR(lp->axi_clk);
 		goto free_netdev;
 	}
-	ret = clk_prepare_enable(lp->axi_clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Unable to enable AXI clock: %d\n", ret);
-		goto free_netdev;
-	}
 
 	lp->misc_clks[0].id = "axis_clk";
 	lp->misc_clks[1].id = "ref_clk";
@@ -2923,7 +2918,6 @@ static int axienet_probe(struct platform_device *pdev)
 		axienet_mdio_teardown(lp);
 cleanup_clk:
 	clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
-	clk_disable_unprepare(lp->axi_clk);
 
 free_netdev:
 	free_netdev(ndev);
@@ -2947,7 +2941,6 @@ static void axienet_remove(struct platform_device *pdev)
 	axienet_mdio_teardown(lp);
 
 	clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks);
-	clk_disable_unprepare(lp->axi_clk);
 
 	free_netdev(ndev);
 }
-- 
2.34.1


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

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

* Re: [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe()
  2024-09-07  3:19 ` [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe() Li Zetao
@ 2024-09-07  5:34   ` Christophe JAILLET
  0 siblings, 0 replies; 15+ messages in thread
From: Christophe JAILLET @ 2024-09-07  5:34 UTC (permalink / raw)
  To: Li Zetao, mchehab, florian.fainelli, andrew, olteanv, davem,
	edumazet, kuba, pabeni, wens, jernej.skrabec, samuel, heiko,
	yisen.zhuang, salil.mehta, hauke, alexandre.torgue, joabreu,
	mcoquelin.stm32, wellslutw, radhey.shyam.pandey, michal.simek,
	hdegoede, ilpo.jarvinen, ruanjinjie, hverkuil-cisco,
	u.kleine-koenig, jacky_chou, jacob.e.keller
  Cc: linux-media, linux-kernel, netdev, linux-arm-kernel, linux-sunxi,
	linux-rockchip, linux-stm32, platform-driver-x86

Le 07/09/2024 à 05:19, Li Zetao a écrit :
> Use devm_clk_get_enabled() instead of devm_clk_get() +
> clk_prepare_enable(), which can make the clk consistent with the device
> life cycle and reduce the risk of unreleased clk resources. Since the
> device framework has automatically released the clk resource, there is
> no need to execute clk_disable_unprepare(clk) on the error path, drop
> the out_clk_disable_unprepare label, and the original error process can
> changed to the out_dispose_mapping error path.
> 
> Signed-off-by: Li Zetao <lizetao1@huawei.com>

Hi,

I think that the subject should be "net: ethernet: allwinner:", or maybe 
even "net: allwinner:"


clk can now be removed from struct emac_board_info I think.
You should check for all patches, as asked in [1].

I've not looked all patches, but lantiq_xrx200() looks also a good 
candidate for removing clk from a structure.

CJ

[1]: https://lore.kernel.org/all/20240903151649.1b466145@kernel.org/

CJ

> ---
>   drivers/net/ethernet/allwinner/sun4i-emac.c | 13 ++-----------
>   1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index d761c08fe5c1..8f42501729b7 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> @@ -1005,22 +1005,16 @@ static int emac_probe(struct platform_device *pdev)
>   	if (emac_configure_dma(db))
>   		netdev_info(ndev, "configure dma failed. disable dma.\n");
>   
> -	db->clk = devm_clk_get(&pdev->dev, NULL);
> +	db->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>   	if (IS_ERR(db->clk)) {
>   		ret = PTR_ERR(db->clk);
>   		goto out_dispose_mapping;
>   	}
>   
> -	ret = clk_prepare_enable(db->clk);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
> -		goto out_dispose_mapping;
> -	}
> -
>   	ret = sunxi_sram_claim(&pdev->dev);
>   	if (ret) {
>   		dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
> -		goto out_clk_disable_unprepare;
> +		goto out_dispose_mapping;
>   	}
>   
>   	db->phy_node = of_parse_phandle(np, "phy-handle", 0);
> @@ -1068,8 +1062,6 @@ static int emac_probe(struct platform_device *pdev)
>   
>   out_release_sram:
>   	sunxi_sram_release(&pdev->dev);
> -out_clk_disable_unprepare:
> -	clk_disable_unprepare(db->clk);
>   out_dispose_mapping:
>   	irq_dispose_mapping(ndev->irq);
>   	dma_release_channel(db->rx_chan);
> @@ -1095,7 +1087,6 @@ static void emac_remove(struct platform_device *pdev)
>   
>   	unregister_netdev(ndev);
>   	sunxi_sram_release(&pdev->dev);
> -	clk_disable_unprepare(db->clk);
>   	irq_dispose_mapping(ndev->irq);
>   	iounmap(db->membase);
>   	free_netdev(ndev);


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

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

* Re: [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled()
  2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
                   ` (9 preceding siblings ...)
  2024-09-07  3:19 ` [PATCH net-next v2 10/10] net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in axienet_probe() Li Zetao
@ 2024-09-11  3:08 ` Jakub Kicinski
  10 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2024-09-11  3:08 UTC (permalink / raw)
  To: Li Zetao
  Cc: mchehab, florian.fainelli, andrew, olteanv, davem, edumazet,
	pabeni, wens, jernej.skrabec, samuel, heiko, yisen.zhuang,
	salil.mehta, hauke, alexandre.torgue, joabreu, mcoquelin.stm32,
	wellslutw, radhey.shyam.pandey, michal.simek, hdegoede,
	ilpo.jarvinen, ruanjinjie, hverkuil-cisco, u.kleine-koenig,
	jacky_chou, jacob.e.keller, linux-media, linux-kernel, netdev,
	linux-arm-kernel, linux-sunxi, linux-rockchip, linux-stm32,
	platform-driver-x86

On Sat, 7 Sep 2024 11:19:16 +0800 Li Zetao wrote:
> v1 -> v2:
>   1) Patch 5 optimizes the check and adds commit information for easier
>   inspection.
>   2) It is no longer necessary to use clk, so delete the clk member of
>   the spl2sw_common structure.
>   3) Remove patches 11 and 12, they should be sent to wireless-next
>   individually

In addition to Christophe's suggestions the patches didn't get ingested
correctly into patchwork, due to the quick repost of:
https://lore.kernel.org/all/20240907031009.3591057-1-lizetao1@huawei.com/
without bumping the patch version...
-- 
pw-bot: cr

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

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

end of thread, other threads:[~2024-09-11  3:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-07  3:19 [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 01/10] net: dsa: bcm_sf2: Convert using devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 02/10] net: ethernet: Convert using devm_clk_get_enabled() in emac_probe() Li Zetao
2024-09-07  5:34   ` Christophe JAILLET
2024-09-07  3:19 ` [PATCH net-next v2 03/10] net: ethernet: arc: " Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 04/10] net: ethernet: ethoc: Convert using devm_clk_get_enabled() in ethoc_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 05/10] net: ftgmac100: Convert using devm_clk_get_enabled() in ftgmac100_setup_clk() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 06/10] net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in hisi_femac_drv_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 07/10] net: lantiq_xrx200: Convert using devm_clk_get_enabled() in xrx200_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 08/10] net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled() in dwc_qos_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 09/10] net: ethernet: sunplus: Convert using devm_clk_get_enabled() in spl2sw_probe() Li Zetao
2024-09-07  3:19 ` [PATCH net-next v2 10/10] net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in axienet_probe() Li Zetao
2024-09-11  3:08 ` [PATCH net-next v2 00/10] net: Convert using devm_clk_get_enabled()/devm_clk_get_optional_enabled() Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2024-09-07  3:09 Li Zetao
2024-09-07  3:03 ` Li Zetao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).