diff mbox series

[net-next,v3,1/9] net: stmmac: dwmac-intel-plat: Convert to devm_clk_get_enabled()

Message ID 20240827095712.2672820-2-frank.li@vivo.com (mailing list archive)
State New, archived
Headers show
Series net: convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() | expand

Commit Message

Yangtao Li Aug. 27, 2024, 9:57 a.m. UTC
Convert devm_clk_get(), clk_prepare_enable() to a single
call to devm_clk_get_enabled(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c    | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Russell King (Oracle) Aug. 27, 2024, 11:20 a.m. UTC | #1
On Tue, Aug 27, 2024 at 03:57:04AM -0600, Yangtao Li wrote:
>  	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
> -	if (ret) {
> -		clk_disable_unprepare(dwmac->tx_clk);
> +	if (ret)
>  		return ret;
> -	}
>  
>  	return 0;

Please head off the next "cleanup" patch that someone has to review,
which will be to convert this to:

	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);

When doing cleanups, don't _create_ new opportunities for cleanups.
Always try to write the best replacement code. This reduces the
burden on reviewers - and we need the burden on reviewers to be
minimised because there's relatively few of them compared to the
number of people generating patches.
Simon Horman Aug. 27, 2024, 2:51 p.m. UTC | #2
On Tue, Aug 27, 2024 at 03:57:04AM -0600, Yangtao Li wrote:
> Convert devm_clk_get(), clk_prepare_enable() to a single
> call to devm_clk_get_enabled(), as this is exactly
> what this function does.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c    | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
> index d68f0c4e7835..dcbae653ab8c 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
> @@ -104,12 +104,10 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
>  
>  		/* Enable TX clock */
>  		if (dwmac->data->tx_clk_en) {
> -			dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
> +			dwmac->tx_clk = devm_clk_get_enabled(&pdev->dev, "tx_clk");

As it looks like there will be a v4 anyway, a minor nit from my side:
IMHO, the line above could be trivially wrapped to keep it <= 80 columns wide,
which is still preferred by Networking code.

>  			if (IS_ERR(dwmac->tx_clk))
>  				return PTR_ERR(dwmac->tx_clk);
>  
> -			clk_prepare_enable(dwmac->tx_clk);
> -
>  			/* Check and configure TX clock rate */
>  			rate = clk_get_rate(dwmac->tx_clk);
>  			if (dwmac->data->tx_clk_rate &&

...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index d68f0c4e7835..dcbae653ab8c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -104,12 +104,10 @@  static int intel_eth_plat_probe(struct platform_device *pdev)
 
 		/* Enable TX clock */
 		if (dwmac->data->tx_clk_en) {
-			dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
+			dwmac->tx_clk = devm_clk_get_enabled(&pdev->dev, "tx_clk");
 			if (IS_ERR(dwmac->tx_clk))
 				return PTR_ERR(dwmac->tx_clk);
 
-			clk_prepare_enable(dwmac->tx_clk);
-
 			/* Check and configure TX clock rate */
 			rate = clk_get_rate(dwmac->tx_clk);
 			if (dwmac->data->tx_clk_rate &&
@@ -149,20 +147,15 @@  static int intel_eth_plat_probe(struct platform_device *pdev)
 	}
 
 	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-	if (ret) {
-		clk_disable_unprepare(dwmac->tx_clk);
+	if (ret)
 		return ret;
-	}
 
 	return 0;
 }
 
 static void intel_eth_plat_remove(struct platform_device *pdev)
 {
-	struct intel_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev);
-
 	stmmac_pltfr_remove(pdev);
-	clk_disable_unprepare(dwmac->tx_clk);
 }
 
 static struct platform_driver intel_eth_plat_driver = {