diff mbox series

[v6,05/13] phy: cadence: cadence-sierra: Move all clk_get_*() to a separate function

Message ID 20210310154558.32078-6-kishon@ti.com
State New
Headers show
Series PHY: Add support in Sierra to use external clock | expand

Commit Message

Kishon Vijay Abraham I March 10, 2021, 3:45 p.m. UTC
No functional change. Group all devm_clk_get_optional() to a
separate function.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

---
 drivers/phy/cadence/phy-cadence-sierra.c | 57 +++++++++++++++---------
 1 file changed, 35 insertions(+), 22 deletions(-)

-- 
2.17.1

Comments

Swapnil Jakhade March 15, 2021, 5:50 a.m. UTC | #1
> -----Original Message-----

> From: Kishon Vijay Abraham I <kishon@ti.com>

> Sent: Wednesday, March 10, 2021 9:16 PM

> To: Kishon Vijay Abraham I <kishon@ti.com>; Vinod Koul

> <vkoul@kernel.org>; Rob Herring <robh+dt@kernel.org>; Philipp Zabel

> <p.zabel@pengutronix.de>; Swapnil Kashinath Jakhade

> <sjakhade@cadence.com>

> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; Lokesh Vutla

> <lokeshvutla@ti.com>

> Subject: [PATCH v6 05/13] phy: cadence: cadence-sierra: Move all clk_get_*()

> to a separate function

> 

> EXTERNAL MAIL

> 

> 

> No functional change. Group all devm_clk_get_optional() to a separate

> function.

> 

> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

> ---

>  drivers/phy/cadence/phy-cadence-sierra.c | 57 +++++++++++++++---------

>  1 file changed, 35 insertions(+), 22 deletions(-)

> 


Reviewed-by: Swapnil Jakhade <sjakhade@cadence.com>


Thanks & regards,
Swapnil

> diff --git a/drivers/phy/cadence/phy-cadence-sierra.c

> b/drivers/phy/cadence/phy-cadence-sierra.c

> index f7ba0ed416bc..7bf1b4c7774a 100644

> --- a/drivers/phy/cadence/phy-cadence-sierra.c

> +++ b/drivers/phy/cadence/phy-cadence-sierra.c

> @@ -477,6 +477,38 @@ static int cdns_regmap_init_blocks(struct

> cdns_sierra_phy *sp,

>  	return 0;

>  }

> 

> +static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,

> +				      struct device *dev)

> +{

> +	struct clk *clk;

> +	int ret;

> +

> +	clk = devm_clk_get_optional(dev, "phy_clk");

> +	if (IS_ERR(clk)) {

> +		dev_err(dev, "failed to get clock phy_clk\n");

> +		return PTR_ERR(clk);

> +	}

> +	sp->clk = clk;

> +

> +	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");

> +	if (IS_ERR(clk)) {

> +		dev_err(dev, "cmn_refclk_dig_div clock not found\n");

> +		ret = PTR_ERR(clk);

> +		return ret;

> +	}

> +	sp->cmn_refclk_dig_div = clk;

> +

> +	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");

> +	if (IS_ERR(clk)) {

> +		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");

> +		ret = PTR_ERR(clk);

> +		return ret;

> +	}

> +	sp->cmn_refclk1_dig_div = clk;

> +

> +	return 0;

> +}

> +

>  static int cdns_sierra_phy_probe(struct platform_device *pdev)  {

>  	struct cdns_sierra_phy *sp;

> @@ -487,7 +519,6 @@ static int cdns_sierra_phy_probe(struct

> platform_device *pdev)

>  	unsigned int id_value;

>  	int i, ret, node = 0;

>  	void __iomem *base;

> -	struct clk *clk;

>  	struct device_node *dn = dev->of_node, *child;

> 

>  	if (of_get_child_count(dn) == 0)

> @@ -524,11 +555,9 @@ static int cdns_sierra_phy_probe(struct

> platform_device *pdev)

> 

>  	platform_set_drvdata(pdev, sp);

> 

> -	sp->clk = devm_clk_get_optional(dev, "phy_clk");

> -	if (IS_ERR(sp->clk)) {

> -		dev_err(dev, "failed to get clock phy_clk\n");

> -		return PTR_ERR(sp->clk);

> -	}

> +	ret = cdns_sierra_phy_get_clocks(sp, dev);

> +	if (ret)

> +		return ret;

> 

>  	sp->phy_rst = devm_reset_control_get(dev, "sierra_reset");

>  	if (IS_ERR(sp->phy_rst)) {

> @@ -542,22 +571,6 @@ static int cdns_sierra_phy_probe(struct

> platform_device *pdev)

>  		return PTR_ERR(sp->apb_rst);

>  	}

> 

> -	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");

> -	if (IS_ERR(clk)) {

> -		dev_err(dev, "cmn_refclk_dig_div clock not found\n");

> -		ret = PTR_ERR(clk);

> -		return ret;

> -	}

> -	sp->cmn_refclk_dig_div = clk;

> -

> -	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");

> -	if (IS_ERR(clk)) {

> -		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");

> -		ret = PTR_ERR(clk);

> -		return ret;

> -	}

> -	sp->cmn_refclk1_dig_div = clk;

> -

>  	ret = clk_prepare_enable(sp->clk);

>  	if (ret)

>  		return ret;

> --

> 2.17.1
diff mbox series

Patch

diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c
index f7ba0ed416bc..7bf1b4c7774a 100644
--- a/drivers/phy/cadence/phy-cadence-sierra.c
+++ b/drivers/phy/cadence/phy-cadence-sierra.c
@@ -477,6 +477,38 @@  static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
 	return 0;
 }
 
+static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
+				      struct device *dev)
+{
+	struct clk *clk;
+	int ret;
+
+	clk = devm_clk_get_optional(dev, "phy_clk");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "failed to get clock phy_clk\n");
+		return PTR_ERR(clk);
+	}
+	sp->clk = clk;
+
+	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
+		ret = PTR_ERR(clk);
+		return ret;
+	}
+	sp->cmn_refclk_dig_div = clk;
+
+	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
+		ret = PTR_ERR(clk);
+		return ret;
+	}
+	sp->cmn_refclk1_dig_div = clk;
+
+	return 0;
+}
+
 static int cdns_sierra_phy_probe(struct platform_device *pdev)
 {
 	struct cdns_sierra_phy *sp;
@@ -487,7 +519,6 @@  static int cdns_sierra_phy_probe(struct platform_device *pdev)
 	unsigned int id_value;
 	int i, ret, node = 0;
 	void __iomem *base;
-	struct clk *clk;
 	struct device_node *dn = dev->of_node, *child;
 
 	if (of_get_child_count(dn) == 0)
@@ -524,11 +555,9 @@  static int cdns_sierra_phy_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, sp);
 
-	sp->clk = devm_clk_get_optional(dev, "phy_clk");
-	if (IS_ERR(sp->clk)) {
-		dev_err(dev, "failed to get clock phy_clk\n");
-		return PTR_ERR(sp->clk);
-	}
+	ret = cdns_sierra_phy_get_clocks(sp, dev);
+	if (ret)
+		return ret;
 
 	sp->phy_rst = devm_reset_control_get(dev, "sierra_reset");
 	if (IS_ERR(sp->phy_rst)) {
@@ -542,22 +571,6 @@  static int cdns_sierra_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(sp->apb_rst);
 	}
 
-	clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
-	if (IS_ERR(clk)) {
-		dev_err(dev, "cmn_refclk_dig_div clock not found\n");
-		ret = PTR_ERR(clk);
-		return ret;
-	}
-	sp->cmn_refclk_dig_div = clk;
-
-	clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
-	if (IS_ERR(clk)) {
-		dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
-		ret = PTR_ERR(clk);
-		return ret;
-	}
-	sp->cmn_refclk1_dig_div = clk;
-
 	ret = clk_prepare_enable(sp->clk);
 	if (ret)
 		return ret;