diff options
author | Rob Herring <robh@kernel.org> | 2018-09-28 15:48:39 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-09-28 15:48:39 -0500 |
commit | 389d0a8a7af8ff8bb6301382333c7e8f748d7cd6 (patch) | |
tree | 8a9704aad28ad8f1c11c947026b0f22dfffb0ca5 /drivers/of/base.c | |
parent | da08d8cb8cfc58a340fc5e163385b5dfd714d762 (diff) | |
parent | 4c29e5934f6c35df2601d593ddfa737b7932bde6 (diff) | |
download | linux-389d0a8a7af8ff8bb6301382333c7e8f748d7cd6.tar.gz linux-389d0a8a7af8ff8bb6301382333c7e8f748d7cd6.tar.bz2 linux-389d0a8a7af8ff8bb6301382333c7e8f748d7cd6.zip |
Merge branch 'dt/cpu-type-rework' into dt/next
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r-- | drivers/of/base.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 17ae594b7014..32444299db45 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -330,6 +330,8 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, ac = of_n_addr_cells(cpun); cell = of_get_property(cpun, prop_name, &prop_len); + if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0)) + return true; if (!cell || !ac) return false; prop_len /= sizeof(*cell) * ac; @@ -390,7 +392,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) { struct device_node *cpun; - for_each_node_by_type(cpun, "cpu") { + for_each_of_cpu_node(cpun) { if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) return cpun; } @@ -745,6 +747,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node, EXPORT_SYMBOL(of_get_next_available_child); /** + * of_get_next_cpu_node - Iterate on cpu nodes + * @prev: previous child of the /cpus node, or NULL to get first + * + * Returns a cpu node pointer with refcount incremented, use of_node_put() + * on it when done. Returns NULL when prev is the last child. Decrements + * the refcount of prev. + */ +struct device_node *of_get_next_cpu_node(struct device_node *prev) +{ + struct device_node *next = NULL; + unsigned long flags; + struct device_node *node; + + if (!prev) + node = of_find_node_by_path("/cpus"); + + raw_spin_lock_irqsave(&devtree_lock, flags); + if (prev) + next = prev->sibling; + else if (node) { + next = node->child; + of_node_put(node); + } + for (; next; next = next->sibling) { + if (!(of_node_name_eq(next, "cpu") || + (next->type && !of_node_cmp(next->type, "cpu")))) + continue; + if (!__of_device_is_available(next)) + continue; + if (of_node_get(next)) + break; + } + of_node_put(prev); + raw_spin_unlock_irqrestore(&devtree_lock, flags); + return next; +} +EXPORT_SYMBOL(of_get_next_cpu_node); + +/** * of_get_compatible_child - Find compatible child node * @parent: parent node * @compatible: compatible string |