* [PATCH net-next] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions
@ 2026-11-24 19:23 Markus Elfring
2026-11-24 20:20 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2026-11-24 19:23 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman
Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
Florian Fainelli, Frank Li
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Nov 2026 19:50:57 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Omit a clk_disable_unprepare() call on error handling paths
and in the implementation of two remove functions.
* Omit two labels.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 26 ++++----------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index f6595fdc888d..e98130092357 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1751,14 +1751,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
priv->irq_rx = irq_rx;
priv->irq_tx = irq_tx;
- priv->mac_clk = devm_clk_get(&pdev->dev, "enet");
+ priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enet");
if (IS_ERR(priv->mac_clk)) {
ret = PTR_ERR(priv->mac_clk);
goto out;
}
- ret = clk_prepare_enable(priv->mac_clk);
- if (ret)
- goto out;
/* initialize default and fetch platform data */
priv->rx_ring_size = BCMENET_DEF_RX_DESC;
@@ -1792,11 +1789,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
if (IS_ERR(priv->phy_clk)) {
ret = PTR_ERR(priv->phy_clk);
priv->phy_clk = NULL;
- goto out_disable_clk_mac;
+ goto out;
}
ret = clk_prepare_enable(priv->phy_clk);
if (ret)
- goto out_disable_clk_mac;
+ goto out;
}
/* do minimal hardware init to be able to probe mii bus */
@@ -1890,8 +1887,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
enet_writel(priv, 0, ENET_MIISC_REG);
clk_disable_unprepare(priv->phy_clk);
-out_disable_clk_mac:
- clk_disable_unprepare(priv->mac_clk);
out:
free_netdev(dev);
return ret;
@@ -1926,9 +1921,7 @@ static void bcm_enet_remove(struct platform_device *pdev)
bcm_enet_mdio_write_mii);
}
- /* disable hw block clocks */
clk_disable_unprepare(priv->phy_clk);
- clk_disable_unprepare(priv->mac_clk);
free_netdev(dev);
}
@@ -2692,14 +2685,11 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
goto out;
}
- priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw");
+ priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enetsw");
if (IS_ERR(priv->mac_clk)) {
ret = PTR_ERR(priv->mac_clk);
goto out;
}
- ret = clk_prepare_enable(priv->mac_clk);
- if (ret)
- goto out;
priv->rx_chan = 0;
priv->tx_chan = 1;
@@ -2718,7 +2708,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
ret = register_netdev(dev);
if (ret)
- goto out_disable_clk;
+ goto out;
netif_carrier_off(dev);
platform_set_drvdata(pdev, dev);
@@ -2727,8 +2717,6 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
return 0;
-out_disable_clk:
- clk_disable_unprepare(priv->mac_clk);
out:
free_netdev(dev);
return ret;
@@ -2738,16 +2726,12 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
/* exit func, stops hardware and unregisters netdevice */
static void bcm_enetsw_remove(struct platform_device *pdev)
{
- struct bcm_enet_priv *priv;
struct net_device *dev;
/* stop netdevice */
dev = platform_get_drvdata(pdev);
- priv = netdev_priv(dev);
unregister_netdev(dev);
- clk_disable_unprepare(priv->mac_clk);
-
free_netdev(dev);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions
2026-11-24 19:23 [PATCH net-next] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring
@ 2026-11-24 20:20 ` Andy Shevchenko
2026-11-24 20:28 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-11-24 20:20 UTC (permalink / raw)
To: Markus Elfring
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli, Frank Li
On Tue, Nov 24, 2026 at 08:23:24PM +0100, Markus Elfring wrote:
>
> * Reuse existing functionality from devm_clk_get_enabled() instead of
> keeping duplicate source code.
>
> * Omit a clk_disable_unprepare() call on error handling paths
> and in the implementation of two remove functions.
>
> * Omit two labels.
>
> This issue was detected by using the Coccinelle software.
...
> -out_disable_clk_mac:
> - clk_disable_unprepare(priv->mac_clk);
> out:
> free_netdev(dev);
> return ret;
Does this have side effects due to order changes? Same Q for the remove stage.
...
> - /* disable hw block clocks */
Why drop this comment?
> clk_disable_unprepare(priv->phy_clk);
> - clk_disable_unprepare(priv->mac_clk);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions
2026-11-24 20:20 ` Andy Shevchenko
@ 2026-11-24 20:28 ` Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2026-11-24 20:28 UTC (permalink / raw)
To: Andy Shevchenko, netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Hemanth Selam,
Jakub Kicinski, Jonas Gorski, Paolo Abeni, Simon Horman, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli, Frank Li
> ...
>
>> - /* disable hw block clocks */
>
> Why drop this comment?
>
>> clk_disable_unprepare(priv->phy_clk);
>> - clk_disable_unprepare(priv->mac_clk);
>
I propose to handle these clocks differently for the affected Linux driver.
https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/net/ethernet/broadcom/bcm63xx_enet.c#L1902-L1934
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 20:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 19:23 [PATCH net-next] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions Markus Elfring
2026-11-24 20:20 ` Andy Shevchenko
2026-11-24 20:28 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox