Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609205

[PATCH v5 3/9] coresight: of_get_coresight_platform_data: Add missing of_node_put

Path csiph.com!news.mixmin.net!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod
From Leo Yan <leo.yan@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v5 3/9] coresight: of_get_coresight_platform_data: Add missing of_node_put
Date Sat, 25 Mar 2017 19:30:02 +0100
Message-ID <toYBQ-4DA-7@gated-at.bofh.it> (permalink)
References <toYBQ-4DA-3@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Av8iWToggPzcj0Ikq904mM+c9jlhlxGamEgFpH5NSk=; b=K14904O/wGulpm0bhInDH0Yvdhqbrr1oIQOKo7xzevswnotbIDqjNeipYdXzfPInRl INuJcMVe+gUHkF4olVDQ3I7VorZJG9UNMdAKi2vSEx+0AFRqzTgGo5SG9KGep59dPIck si3cocOY9oW4XN6II7TBV7TJW+aADgZ6mvOiI=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3Av8iWToggPzcj0Ikq904mM+c9jlhlxGamEgFpH5NSk=; b=od0idJLrDs5S4WOFUkoyxcqqRRuu8Gb461Qb20h9LRMLkhOLRh+1nrk/ZseFANQQS2 Fe+8uYCa/q/a0P+wj+76wqs/cM4ZBNXse+SBF+zPpR5kG0X0Twv3C7whGRrlrlqUM7Cs BUb0JcLx4SUMY2dmADp1h59olpdSZuK26wmrpq4T3jowJ4epk6KOwVH6rt974XB127Gp IohPPvNhySi9ts9HCiXKxeUkuLengJKiRlNkPgNmhoFAPhit6VgQcmfydeZGmSFmX6sZ 2C3K+QpsaWGGMlNDxFpvWz995n+J5FuSSgc/Z8SoCgEU6OBJBVEoRgZuXaBrPCnCSRLq DAgg==
X-Gm-Message-State AFeK/H159OzMoinGtF1MgYa9z6OmWkSfwk0BFHoTXc7dvC4wnZa8y4jYXtjSQDVRlNqXjrFy
X-Received by 10.28.105.92 with SMTP id e89mr2683771wmc.93.1490466255415; Sat, 25 Mar 2017 11:24:15 -0700 (PDT)
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 59
Organization linux.* mail to news gateway
X-Original-Cc Suzuki K Poulose <suzuki.poulose@arm.com>, Leo Yan <leo.yan@linaro.org>
X-Original-Date Sun, 26 Mar 2017 02:23:11 +0800
X-Original-Message-ID <1490466197-29163-4-git-send-email-leo.yan@linaro.org>
X-Original-References <1490466197-29163-1-git-send-email-leo.yan@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1609205

Show key headers only | View raw


From: Suzuki K Poulose <suzuki.poulose@arm.com>

The of_get_coresight_platform_data iterates over the possible CPU nodes
to find a given cpu phandle. However it does not drop the reference
to the node pointer returned by the of_get_coresight_platform_data.

This patch also introduces another minor fix is to use
of_cpu_device_node_get() to replace of_get_cpu_node().

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
[Leo: minor tweaks for of_get_coresight_platform_data]
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 drivers/hwtracing/coresight/of_coresight.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 629e031..1a77280 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -108,7 +108,8 @@ struct coresight_platform_data *of_get_coresight_platform_data(
 	struct coresight_platform_data *pdata;
 	struct of_endpoint endpoint, rendpoint;
 	struct device *rdev;
-	struct device_node *dn;
+	bool found;
+	struct device_node *dn, *np;
 	struct device_node *ep = NULL;
 	struct device_node *rparent = NULL;
 	struct device_node *rport = NULL;
@@ -175,17 +176,19 @@ struct coresight_platform_data *of_get_coresight_platform_data(
 		} while (ep);
 	}
 
-	/* Affinity defaults to CPU0 */
-	pdata->cpu = 0;
 	dn = of_parse_phandle(node, "cpu", 0);
-	for (cpu = 0; dn && cpu < nr_cpu_ids; cpu++) {
-		if (dn == of_get_cpu_node(cpu, NULL)) {
-			pdata->cpu = cpu;
+	for_each_possible_cpu(cpu) {
+		np = of_cpu_device_node_get(cpu);
+		found = (dn == np);
+		of_node_put(np);
+		if (found)
 			break;
-		}
 	}
 	of_node_put(dn);
 
+	/* Affinity to CPU0 if no cpu nodes are found */
+	pdata->cpu = found ? cpu : 0;
+
 	return pdata;
 }
 EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v5 3/9] coresight: of_get_coresight_platform_data: Add missing of_node_put Leo Yan <leo.yan@linaro.org> - 2017-03-25 19:30 +0100

csiph-web