# Re: \[PATCH net-next\] bcm63xx\_enet: Use devm\_clk\_get\_enabled() in two probe functions

- From: Christophe JAILLET \<hidden\>
- Date: 2026-11-25 18:17:49 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/11/18026072
- Thread: https://ratatoskr.run/netdev/2026/11/18015206/t.md

```text
Le 24/11/2026 à 20:23, Markus Elfring a écrit :
> From: Markus Elfring <redacted>
> 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 <redacted>
> ---
>   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);
>   }
>   

Why changing only one devm_clk_get()?

CJ
```
