* [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times
@ 2015-02-24 11:52 Axel Lin
2015-02-24 11:53 ` [PATCH 2/2] phy: miphy365x: " Axel Lin
2015-02-24 13:47 ` [PATCH 1/2] phy: miphy28lp: " Kishon Vijay Abraham I
0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2015-02-24 11:52 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Gabriel FERNANDEZ, Lee Jones, Alexandre Torgue, linux-kernel
Currently, of_get_child_count() is called in each iteration of the for loop in
miphy28lp_xlate(). This patch stores the return value of of_get_child_count()
in miphy_dev->nphys and call of_get_child_count() once in miphy28lp_probe().
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/phy/phy-miphy28lp.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
index 9b2848e..d444932 100644
--- a/drivers/phy/phy-miphy28lp.c
+++ b/drivers/phy/phy-miphy28lp.c
@@ -228,6 +228,7 @@ struct miphy28lp_dev {
struct regmap *regmap;
struct mutex miphy_mutex;
struct miphy28lp_phy **phys;
+ int nphys;
};
struct miphy_initval {
@@ -1116,7 +1117,7 @@ static struct phy *miphy28lp_xlate(struct device *dev,
return ERR_PTR(-EINVAL);
}
- for (index = 0; index < of_get_child_count(dev->of_node); index++)
+ for (index = 0; index < miphy_dev->nphys; index++)
if (phynode == miphy_dev->phys[index]->phy->dev.of_node) {
miphy_phy = miphy_dev->phys[index];
break;
@@ -1200,15 +1201,15 @@ static int miphy28lp_probe(struct platform_device *pdev)
struct miphy28lp_dev *miphy_dev;
struct phy_provider *provider;
struct phy *phy;
- int chancount, port = 0;
- int ret;
+ int ret, port = 0;
miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
if (!miphy_dev)
return -ENOMEM;
- chancount = of_get_child_count(np);
- miphy_dev->phys = devm_kzalloc(&pdev->dev, sizeof(phy) * chancount,
+ miphy_dev->nphys = of_get_child_count(np);
+ miphy_dev->phys = devm_kzalloc(&pdev->dev,
+ sizeof(phy) * miphy_dev->nphys,
GFP_KERNEL);
if (!miphy_dev->phys)
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] phy: miphy365x: Avoid calling of_get_child_count() multiple times
2015-02-24 11:52 [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Axel Lin
@ 2015-02-24 11:53 ` Axel Lin
2015-02-24 13:47 ` [PATCH 1/2] phy: miphy28lp: " Kishon Vijay Abraham I
1 sibling, 0 replies; 4+ messages in thread
From: Axel Lin @ 2015-02-24 11:53 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Gabriel FERNANDEZ, Lee Jones, Alexandre Torgue, linux-kernel
Currently, of_get_child_count() is called in each iteration of the for loop in
miphy365x_xlate(). This patch stores the return value of of_get_child_count()
in miphy_dev->nphys and call of_get_child_count() once in miphy365x_probe().
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/phy/phy-miphy365x.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/phy-miphy365x.c b/drivers/phy/phy-miphy365x.c
index 6c80154..61177a6 100644
--- a/drivers/phy/phy-miphy365x.c
+++ b/drivers/phy/phy-miphy365x.c
@@ -150,6 +150,7 @@ struct miphy365x_dev {
struct regmap *regmap;
struct mutex miphy_mutex;
struct miphy365x_phy **phys;
+ int nphys;
};
/*
@@ -485,7 +486,7 @@ static struct phy *miphy365x_xlate(struct device *dev,
return ERR_PTR(-EINVAL);
}
- for (index = 0; index < of_get_child_count(dev->of_node); index++)
+ for (index = 0; index < miphy_dev->nphys; index++)
if (phynode == miphy_dev->phys[index]->phy->dev.of_node) {
miphy_phy = miphy_dev->phys[index];
break;
@@ -541,15 +542,15 @@ static int miphy365x_probe(struct platform_device *pdev)
struct miphy365x_dev *miphy_dev;
struct phy_provider *provider;
struct phy *phy;
- int chancount, port = 0;
- int ret;
+ int ret, port = 0;
miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
if (!miphy_dev)
return -ENOMEM;
- chancount = of_get_child_count(np);
- miphy_dev->phys = devm_kzalloc(&pdev->dev, sizeof(phy) * chancount,
+ miphy_dev->nphys = of_get_child_count(np);
+ miphy_dev->phys = devm_kzalloc(&pdev->dev,
+ sizeof(phy) * miphy_dev->nphys,
GFP_KERNEL);
if (!miphy_dev->phys)
return -ENOMEM;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times
2015-02-24 11:52 [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Axel Lin
2015-02-24 11:53 ` [PATCH 2/2] phy: miphy365x: " Axel Lin
@ 2015-02-24 13:47 ` Kishon Vijay Abraham I
2015-02-24 13:53 ` Axel Lin
1 sibling, 1 reply; 4+ messages in thread
From: Kishon Vijay Abraham I @ 2015-02-24 13:47 UTC (permalink / raw)
To: Axel Lin; +Cc: Gabriel FERNANDEZ, Lee Jones, Alexandre Torgue, linux-kernel
Hi,
On Tuesday 24 February 2015 05:22 PM, Axel Lin wrote:
> Currently, of_get_child_count() is called in each iteration of the for loop in
> miphy28lp_xlate(). This patch stores the return value of of_get_child_count()
> in miphy_dev->nphys and call of_get_child_count() once in miphy28lp_probe().
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/phy/phy-miphy28lp.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
> index 9b2848e..d444932 100644
> --- a/drivers/phy/phy-miphy28lp.c
> +++ b/drivers/phy/phy-miphy28lp.c
> @@ -228,6 +228,7 @@ struct miphy28lp_dev {
> struct regmap *regmap;
> struct mutex miphy_mutex;
> struct miphy28lp_phy **phys;
> + int nphys;
it can just be a local member to miphy28lp_xlate() since it's not used anywhere
else.
Cheers
Kishon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times
2015-02-24 13:47 ` [PATCH 1/2] phy: miphy28lp: " Kishon Vijay Abraham I
@ 2015-02-24 13:53 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2015-02-24 13:53 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Gabriel FERNANDEZ, Lee Jones, Alexandre Torgue, linux-kernel
2015-02-24 21:47 GMT+08:00 Kishon Vijay Abraham I <kishon@ti.com>:
> Hi,
>
> On Tuesday 24 February 2015 05:22 PM, Axel Lin wrote:
>>
>> Currently, of_get_child_count() is called in each iteration of the for
>> loop in
>> miphy28lp_xlate(). This patch stores the return value of
>> of_get_child_count()
>> in miphy_dev->nphys and call of_get_child_count() once in
>> miphy28lp_probe().
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>> ---
>> drivers/phy/phy-miphy28lp.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/phy/phy-miphy28lp.c b/drivers/phy/phy-miphy28lp.c
>> index 9b2848e..d444932 100644
>> --- a/drivers/phy/phy-miphy28lp.c
>> +++ b/drivers/phy/phy-miphy28lp.c
>> @@ -228,6 +228,7 @@ struct miphy28lp_dev {
>> struct regmap *regmap;
>> struct mutex miphy_mutex;
>> struct miphy28lp_phy **phys;
>> + int nphys;
>
>
> it can just be a local member to miphy28lp_xlate() since it's not used
> anywhere else.
It's used in both miphy28lp_probe() and miphy28lp_xlate().
miphy_dev->phys replaces the chancount local variable as well.
Regards,
Axel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-24 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-24 11:52 [PATCH 1/2] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Axel Lin
2015-02-24 11:53 ` [PATCH 2/2] phy: miphy365x: " Axel Lin
2015-02-24 13:47 ` [PATCH 1/2] phy: miphy28lp: " Kishon Vijay Abraham I
2015-02-24 13:53 ` Axel Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).