Subject: Re: [net-next v3 8/9] net: mvpp2: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled()

From: Simon Horman <[email-masked]>
Date: Tue, 27 Aug 2024 15:55:25 +0100

On Tue, Aug 27, 2024 at 03:57:11AM -0600, Yangtao Li wrote:
> Use devm_clk_get_enabled() and devm_clk_get_optional_enabled()
> to simplify code.
> 
> Signed-off-by: Yangtao Li <[email-masked]>
> Reviewed-by: Maxime Chevallier <[email-masked]>
> Tested-by: Maxime Chevallier <[email-masked]>
> Suggested-by: Christophe JAILLET <[email-masked]>
> Reviewed-by: Marcin Wojtas <[email-masked]>

...

> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 2fe8bae4eb3c..0ca2daeb0f90 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -7561,56 +7561,32 @@ static int mvpp2_probe(struct platform_device *pdev)

...

> -		priv->axi_clk = devm_clk_get_optional(&pdev->dev, "axi_clk");
> -		if (IS_ERR(priv->axi_clk)) {
> -			err = PTR_ERR(priv->axi_clk);
> -			goto err_mg_core_clk;
> +			clk = devm_clk_get_optional_enabled(&pdev->dev, "mg_core_clk");

As it looks like there will be a v3 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(clk))
> +				return PTR_ERR(clk);
>  		}
>  
> -		err = clk_prepare_enable(priv->axi_clk);
> -		if (err < 0)
> -			goto err_mg_core_clk;
> -
> -		/* Get system's tclk rate */
> -		priv->tclk = clk_get_rate(priv->pp_clk);
> +		clk = devm_clk_get_optional_enabled(&pdev->dev, "axi_clk");
> +		if (IS_ERR(clk))
> +			return PTR_ERR(clk);

...