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


Groups > linux.kernel > #1694610 > unrolled thread

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

Started bySuzuki K Poulose <suzuki.poulose@arm.com>
First post2017-07-24 12:40 +0200
Last post2017-07-25 18:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 3/6] coresight: of: Use of_device_node_get_cpu helper Suzuki K Poulose <suzuki.poulose@arm.com> - 2017-07-24 12:40 +0200
    Re: [PATCH v2 3/6] coresight: of: Use of_device_node_get_cpu helper Mathieu Poirier <mathieu.poirier@linaro.org> - 2017-07-25 18:20 +0200

#1694610 — [PATCH v2 3/6] coresight: of: Use of_device_node_get_cpu helper

FromSuzuki K Poulose <suzuki.poulose@arm.com>
Date2017-07-24 12:40 +0200
Subject[PATCH v2 3/6] coresight: of: Use of_device_node_get_cpu helper
Message-ID<u6IWm-3vE-5@gated-at.bofh.it>
Reuse the new generic helper, of_device_node_get_cpu() to map a
given CPU phandle to a logical CPU number.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Leo Yan <leo.yan@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

[toc] | [next] | [standalone]


#1695927

FromMathieu Poirier <mathieu.poirier@linaro.org>
Date2017-07-25 18:20 +0200
Message-ID<u7aIW-539-23@gated-at.bofh.it>
In reply to#1694610
On 24 July 2017 at 04:29, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> Reuse the new generic helper, of_device_node_get_cpu() to map a
> given CPU phandle to a logical CPU number.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Leo Yan <leo.yan@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);
>

Acked-by: Mathieu Poirier <mathieu.poirier@linaro,org>

> --
> 2.7.5
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web