coresight: Return error if no cpu nodes are found

By default if no node found the function of_coresight_get_cpu return CPU0
which will cause problem when CPU0 etm probe. So should return invalid
value in case of no nodes found.

Change-Id: I2d034ffc195c6f25adb1fb8b3413dbc323825bd6
Signed-off-by: Shaoqing Liu <shaoqingliu@codeaurora.org>
This commit is contained in:
Shaoqing Liu 2019-03-07 13:17:54 +08:00 committed by Gerrit - the friendly Code Review server
parent bc1f52b9be
commit be9d6002d6
2 changed files with 6 additions and 4 deletions

View File

@ -592,6 +592,9 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id)
return -ENOMEM;
drvdata->cpu = np ? of_coresight_get_cpu(np) : 0;
if (drvdata->cpu < 0)
return -ENODEV;
if (per_cpu(debug_drvdata, drvdata->cpu)) {
dev_err(dev, "CPU%d drvdata has already been initialized\n",
drvdata->cpu);

View File

@ -107,14 +107,13 @@ int of_coresight_get_cpu(const struct device_node *node)
struct device_node *dn;
dn = of_parse_phandle(node, "cpu", 0);
/* Affinity defaults to CPU0 */
/* Affinity defaults to invalid */
if (!dn)
return 0;
return -ENODEV;
cpu = of_cpu_node_to_id(dn);
of_node_put(dn);
/* Affinity to CPU0 if no cpu nodes are found */
return (cpu < 0) ? 0 : cpu;
return cpu;
}
EXPORT_SYMBOL_GPL(of_coresight_get_cpu);