From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932134AbbCMMCJ (ORCPT ); Fri, 13 Mar 2015 08:02:09 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:41727 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762AbbCMMCD (ORCPT ); Fri, 13 Mar 2015 08:02:03 -0400 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 01/20] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Date: Fri, 13 Mar 2015 17:31:38 +0530 Message-ID: <1426248117-14312-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426248117-14312-1-git-send-email-kishon@ti.com> References: <1426248117-14312-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin 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 Signed-off-by: Kishon Vijay Abraham I --- 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.7.9.5