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


Groups > linux.kernel > #1698090

[PATCH v3 3/6] coresight: of: Use of_device_node_get_cpu helper

From Suzuki K Poulose <suzuki.poulose@arm.com>
Newsgroups linux.kernel
Subject [PATCH v3 3/6] coresight: of: Use of_device_node_get_cpu helper
Date 2017-07-27 17:20 +0200
Message-ID <u7SJY-7Iw-29@gated-at.bofh.it> (permalink)
References <u7SJX-7Iw-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Reuse the new generic helper, of_device_node_get_cpu() to map a
given CPU phandle to a logical CPU number.

Cc: Leo Yan <leo.yan@linaro.org>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/of_coresight.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index a187941..42ce9f8 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -16,6 +16,7 @@
 #include <linux/clk.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_graph.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
@@ -104,26 +105,17 @@ static int of_coresight_alloc_memory(struct device *dev,
 int of_coresight_get_cpu(const struct device_node *node)
 {
 	int cpu;
-	bool found;
-	struct device_node *dn, *np;
+	struct device_node *dn;
 
 	dn = of_parse_phandle(node, "cpu", 0);
-
 	/* Affinity defaults to CPU0 */
 	if (!dn)
 		return 0;
-
-	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);
-
+	cpu = of_device_node_get_cpu(dn);
 	/* Affinity to CPU0 if no cpu nodes are found */
-	return found ? cpu : 0;
+	if (cpu >= nr_cpu_ids)
+		return 0;
+	return cpu;
 }
 EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
 
-- 
2.7.5

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/6] perf: Support for ARM DynamIQ Shared Unit PMU Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200
  [PATCH v3 5/6] dt-bindings: Document devicetree binding for ARM DSU PMU Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200
    Re: [PATCH v3 5/6] dt-bindings: Document devicetree binding for ARM  DSU PMU Rob Herring <robh@kernel.org> - 2017-07-27 18:00 +0200
      Re: [PATCH v3 5/6] dt-bindings: Document devicetree binding for ARM  DSU PMU Suzuki K Poulose <Suzuki.Poulose@arm.com> - 2017-07-27 18:10 +0200
  [PATCH v3 4/6] irqchip: gic-v3: Use of_device_node_get_cpu helper Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200
  [PATCH v3 6/6] perf: ARM DynamIQ Shared Unit PMU support Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200
  [PATCH v3 1/6] perf: Export perf_event_update_userpage Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200
  [PATCH v3 3/6] coresight: of: Use of_device_node_get_cpu helper Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-27 17:20 +0200

csiph-web