Commit 21647f73 authored by Axel Lin's avatar Axel Lin Committed by Kishon Vijay Abraham I

phy: miphy28lp: Avoid calling of_get_child_count() multiple times

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: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent c517d838
...@@ -228,6 +228,7 @@ struct miphy28lp_dev { ...@@ -228,6 +228,7 @@ struct miphy28lp_dev {
struct regmap *regmap; struct regmap *regmap;
struct mutex miphy_mutex; struct mutex miphy_mutex;
struct miphy28lp_phy **phys; struct miphy28lp_phy **phys;
int nphys;
}; };
struct miphy_initval { struct miphy_initval {
...@@ -1116,7 +1117,7 @@ static struct phy *miphy28lp_xlate(struct device *dev, ...@@ -1116,7 +1117,7 @@ static struct phy *miphy28lp_xlate(struct device *dev,
return ERR_PTR(-EINVAL); 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) { if (phynode == miphy_dev->phys[index]->phy->dev.of_node) {
miphy_phy = miphy_dev->phys[index]; miphy_phy = miphy_dev->phys[index];
break; break;
...@@ -1200,15 +1201,15 @@ static int miphy28lp_probe(struct platform_device *pdev) ...@@ -1200,15 +1201,15 @@ static int miphy28lp_probe(struct platform_device *pdev)
struct miphy28lp_dev *miphy_dev; struct miphy28lp_dev *miphy_dev;
struct phy_provider *provider; struct phy_provider *provider;
struct phy *phy; struct phy *phy;
int chancount, port = 0; int ret, port = 0;
int ret;
miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL); miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
if (!miphy_dev) if (!miphy_dev)
return -ENOMEM; return -ENOMEM;
chancount = of_get_child_count(np); miphy_dev->nphys = of_get_child_count(np);
miphy_dev->phys = devm_kzalloc(&pdev->dev, sizeof(phy) * chancount, miphy_dev->phys = devm_kzalloc(&pdev->dev,
sizeof(phy) * miphy_dev->nphys,
GFP_KERNEL); GFP_KERNEL);
if (!miphy_dev->phys) if (!miphy_dev->phys)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment