linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <kishon@ti.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 02/20] phy: miphy365x: Avoid calling of_get_child_count() multiple times
Date: Fri, 13 Mar 2015 17:31:39 +0530	[thread overview]
Message-ID: <1426248117-14312-3-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1426248117-14312-1-git-send-email-kishon@ti.com>

From: Axel Lin <axel.lin@ingics.com>

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>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.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.7.9.5


  parent reply	other threads:[~2015-03-13 12:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 12:01 [GIT PULL 00/20] phy: for 4.0 -rc cycle Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 01/20] phy: miphy28lp: Avoid calling of_get_child_count() multiple times Kishon Vijay Abraham I
2015-03-13 12:01 ` Kishon Vijay Abraham I [this message]
2015-03-13 12:01 ` [PATCH 03/20] phy: armada375-usb2: Set drvdata for phy and use it Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 04/20] phy: xgene: Remove duplicate code to set ctx->dev Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 05/20] phy: miphy28lp: Add missing .owner field in miphy28lp_ops Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 06/20] phy: exynos-mipi-video: Fixup the test for state->regmap Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 07/20] phy: exynos-mipi-video: Use spin_lock to protct state->regmap rmw operations Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 08/20] phy: exynos-dp-video: Kill exynos_dp_video_phy_pwr_isol function Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 09/20] phy: hix5hd2-sata: Check return value of platform_get_resource Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 10/20] phy: samsung-usb2: Remove NULL terminating entry from phys array Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 11/20] phy: ti-pipe3: Simplify ti_pipe3_dpll_wait_lock implementation Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 12/20] phy: rockchip-usb: Fixup rockchip_usb_phy_power_on failure path Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 13/20] phy: Find the right match in devm_phy_destroy() Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 14/20] phy: exynos5-usbdrd: Fix off-by-one valid value checking for args->args[0] Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 15/20] phy: twl4030-usb: Remove redundant assignment for twl->linkstat Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 16/20] phy: miphy365x: Convert to devm_kcalloc and fix wrong sizeof Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 17/20] phy: miphy28lp: Convert to devm_kcalloc and fix wrong sizof Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 18/20] phy: core: Fixup return value of phy_exit when !pm_runtime_enabled Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 19/20] phy: ti/omap: Fix modalias Kishon Vijay Abraham I
2015-03-13 12:01 ` [PATCH 20/20] phy: omap-usb2: Fix missing clk_prepare call when using old dt name Kishon Vijay Abraham I
2015-03-14  8:50 ` [GIT PULL 00/20] phy: for 4.0 -rc cycle Greg KH
2015-03-14 11:23   ` Kishon Vijay Abraham I
2015-03-14 11:31   ` [RESEND GIT PULL] " Kishon Vijay Abraham I
2015-03-18 16:28     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426248117-14312-3-git-send-email-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).