Commit 29198e38 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Will Deacon

coresight: of: Use of_cpu_node_to_id helper

Reuse the new generic helper, of_cpu_node_to_id() to map a
given CPU phandle to a logical CPU number.
Acked-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Tested-by: default avatarLeo Yan <leo.yan@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent a0e71cd9
...@@ -104,26 +104,17 @@ static int of_coresight_alloc_memory(struct device *dev, ...@@ -104,26 +104,17 @@ static int of_coresight_alloc_memory(struct device *dev,
int of_coresight_get_cpu(const struct device_node *node) int of_coresight_get_cpu(const struct device_node *node)
{ {
int cpu; int cpu;
bool found; struct device_node *dn;
struct device_node *dn, *np;
dn = of_parse_phandle(node, "cpu", 0); dn = of_parse_phandle(node, "cpu", 0);
/* Affinity defaults to CPU0 */ /* Affinity defaults to CPU0 */
if (!dn) if (!dn)
return 0; return 0;
cpu = of_cpu_node_to_id(dn);
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); of_node_put(dn);
/* Affinity to CPU0 if no cpu nodes are found */ /* 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); EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment