[PATCH] phy: amlogic: use devm_clk_get_enabled() to simplify the code

Neil Armstrong narmstrong at baylibre.com
Wed Aug 31 01:58:35 PDT 2022


On 30/08/2022 19:16, Heiner Kallweit wrote:
> Simplify the code by using devm_clk_get_enabled().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com>
> ---
>   .../phy/amlogic/phy-meson-g12a-usb3-pcie.c    | 32 ++++---------------
>   1 file changed, 6 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
> index 54d65a6f0..d2a1da8d9 100644
> --- a/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
> +++ b/drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
> @@ -388,7 +388,6 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
>   	struct phy_g12a_usb3_pcie_priv *priv;
>   	struct phy_provider *phy_provider;
>   	void __iomem *base;
> -	int ret;
>   
>   	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>   	if (!priv)
> @@ -408,43 +407,24 @@ static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
>   	if (IS_ERR(priv->regmap_cr))
>   		return PTR_ERR(priv->regmap_cr);
>   
> -	priv->clk_ref = devm_clk_get(dev, "ref_clk");
> +	priv->clk_ref = devm_clk_get_enabled(dev, "ref_clk");
>   	if (IS_ERR(priv->clk_ref))
>   		return PTR_ERR(priv->clk_ref);
>   
> -	ret = clk_prepare_enable(priv->clk_ref);
> -	if (ret)
> -		return ret;
> -
>   	priv->reset = devm_reset_control_array_get_exclusive(dev);
> -	if (IS_ERR(priv->reset)) {
> -		ret = PTR_ERR(priv->reset);
> -		goto err_disable_clk_ref;
> -	}
> +	if (IS_ERR(priv->reset))
> +		return PTR_ERR(priv->reset);
>   
>   	priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops);
> -	if (IS_ERR(priv->phy)) {
> -		ret = PTR_ERR(priv->phy);
> -		dev_err_probe(dev, ret, "failed to create PHY\n");
> -		goto err_disable_clk_ref;
> -	}
> +	if (IS_ERR(priv->phy))
> +		return dev_err_probe(dev, PTR_ERR(priv->phy), "failed to create PHY\n");
>   
>   	phy_set_drvdata(priv->phy, priv);
>   	dev_set_drvdata(dev, priv);
>   
>   	phy_provider = devm_of_phy_provider_register(dev,
>   						     phy_g12a_usb3_pcie_xlate);
> -	if (IS_ERR(phy_provider)) {
> -		ret = PTR_ERR(phy_provider);
> -		goto err_disable_clk_ref;
> -	}
> -
> -	return 0;
> -
> -err_disable_clk_ref:
> -	clk_disable_unprepare(priv->clk_ref);
> -
> -	return ret;
> +	return PTR_ERR_OR_ZERO(phy_provider);
>   }
>   
>   static const struct of_device_id phy_g12a_usb3_pcie_of_match[] = {

Reviewed-by: Neil Armstrong <narmstrong at baylibre.com>



More information about the linux-phy mailing list