diff mbox series

[RFC,v3,net-next,01/11] net: ethernet: ti: cpts: use devm_get_clk_from_child

Message ID 1556144667-27997-2-git-send-email-grygorii.strashko@ti.com
State RFC
Delegated to: David Miller
Headers show
Series net: ethernet: ti: introduce new cpsw switchdev based driver | expand

Commit Message

Grygorii Strashko April 24, 2019, 10:24 p.m. UTC
Use devm_get_clk_from_child() instead of devm_clk_get() and this way allow
to group CPTS DT properties in sub-node for better code readability and
maintenance.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn April 24, 2019, 10:46 p.m. UTC | #1
On Thu, Apr 25, 2019 at 01:24:17AM +0300, Grygorii Strashko wrote:
> Use devm_get_clk_from_child() instead of devm_clk_get() and this way allow
> to group CPTS DT properties in sub-node for better code readability and
> maintenance.
> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
>  drivers/net/ethernet/ti/cpts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
> index 499806ce4cd5..aad118e71b61 100644
> --- a/drivers/net/ethernet/ti/cpts.c
> +++ b/drivers/net/ethernet/ti/cpts.c
> @@ -572,7 +572,7 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
>  	if (ret)
>  		return ERR_PTR(ret);
>  
> -	cpts->refclk = devm_clk_get(dev, "cpts");
> +	cpts->refclk = devm_get_clk_from_child(dev, node, "cpts");
>  	if (IS_ERR(cpts->refclk)) {
>  		dev_err(dev, "Failed to get cpts refclk\n");
>  		return ERR_CAST(cpts->refclk);

Hi Grygorii

Does this break backwards compatibility for existing DT blobs?
Maybe you need to look in both the old and new locations?

      Andrew
Grygorii Strashko April 25, 2019, 10:05 a.m. UTC | #2
On 25.04.19 01:46, Andrew Lunn wrote:
> On Thu, Apr 25, 2019 at 01:24:17AM +0300, Grygorii Strashko wrote:
>> Use devm_get_clk_from_child() instead of devm_clk_get() and this way allow
>> to group CPTS DT properties in sub-node for better code readability and
>> maintenance.
>>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>> ---
>>  drivers/net/ethernet/ti/cpts.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
>> index 499806ce4cd5..aad118e71b61 100644
>> --- a/drivers/net/ethernet/ti/cpts.c
>> +++ b/drivers/net/ethernet/ti/cpts.c
>> @@ -572,7 +572,7 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
>>  	if (ret)
>>  		return ERR_PTR(ret);
>>  
>> -	cpts->refclk = devm_clk_get(dev, "cpts");
>> +	cpts->refclk = devm_get_clk_from_child(dev, node, "cpts");
>>  	if (IS_ERR(cpts->refclk)) {
>>  		dev_err(dev, "Failed to get cpts refclk\n");
>>  		return ERR_CAST(cpts->refclk);
> 
> Hi Grygorii
> 
> Does this break backwards compatibility for existing DT blobs?
> Maybe you need to look in both the old and new locations?

No. It doesn't - default node is cpsw->dev->of_node.

Then Patch 7 changes it fro new driver to 
-	cpsw->cpts = cpts_create(cpsw->dev, cpts_regs, cpsw->dev->of_node);
+	cpts_node = of_get_child_by_name(cpsw->dev->of_node, "cpts");
+	if (!cpts_node)
+		cpts_node = cpsw->dev->of_node;
+
+	cpsw->cpts = cpts_create(cpsw->dev, cpts_regs, cpts_node);
Andrew Lunn April 25, 2019, 12:18 p.m. UTC | #3
> > Hi Grygorii
> > 
> > Does this break backwards compatibility for existing DT blobs?
> > Maybe you need to look in both the old and new locations?
> 
> No. It doesn't - default node is cpsw->dev->of_node.

O.K. great. Maybe mention this in the commit message if there is a v2.

     Thanks
        Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
index 499806ce4cd5..aad118e71b61 100644
--- a/drivers/net/ethernet/ti/cpts.c
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -572,7 +572,7 @@  struct cpts *cpts_create(struct device *dev, void __iomem *regs,
 	if (ret)
 		return ERR_PTR(ret);
 
-	cpts->refclk = devm_clk_get(dev, "cpts");
+	cpts->refclk = devm_get_clk_from_child(dev, node, "cpts");
 	if (IS_ERR(cpts->refclk)) {
 		dev_err(dev, "Failed to get cpts refclk\n");
 		return ERR_CAST(cpts->refclk);