Skip to content

Commit

Permalink
coresight: of: Use of_cpu_node_to_id helper
Browse files Browse the repository at this point in the history
Reuse the new generic helper, of_cpu_node_to_id() to map a
given CPU phandle to a logical CPU number.

Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Suzuki K Poulose authored and Will Deacon committed Jan 2, 2018
1 parent a0e71cd commit 29198e3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions drivers/hwtracing/coresight/of_coresight.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,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;
}
cpu = of_cpu_node_to_id(dn);
of_node_put(dn);

/* Affinity to CPU0 if no cpu nodes are found */
return found ? cpu : 0;
return (cpu < 0) ? 0 : cpu;
}
EXPORT_SYMBOL_GPL(of_coresight_get_cpu);

Expand Down

0 comments on commit 29198e3

Please sign in to comment.