All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] Use devicetree to determine present cpus (v2)
@ 2021-02-08 14:28 ` Jan Henrik Weinstock
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Henrik Weinstock @ 2021-02-08 14:28 UTC (permalink / raw)
  To: geert, jonas, stefan.kristiansson, shorne, openrisc, linux-kernel
  Cc: Jan Henrik Weinstock

Signed-off-by: Jan Henrik Weinstock <jan.weinstock@rwth-aachen.de>
---
 arch/openrisc/kernel/smp.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/arch/openrisc/kernel/smp.c b/arch/openrisc/kernel/smp.c
index 75be7e34f..83cbf43d4 100644
--- a/arch/openrisc/kernel/smp.c
+++ b/arch/openrisc/kernel/smp.c
@@ -61,32 +61,31 @@ void __init smp_prepare_boot_cpu(void)
 
 void __init smp_init_cpus(void)
 {
-	int i;
+	struct device_node* cpu;
+	u32 cpu_id;
+
+	for_each_of_cpu_node(cpu) {
+		if (of_property_read_u32(cpu, "reg", &cpu_id)) {
+			pr_warn("%s missing reg property", cpu->full_name);
+			continue;
+		}
 
-	for (i = 0; i < NR_CPUS; i++)
-		set_cpu_possible(i, true);
+		if (cpu_id < NR_CPUS)
+			set_cpu_possible(cpu_id, true);
+	}
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-	u32 cpu_id;
-	struct device_node *cpu, *cpus;
+	unsigned int cpu;
 
 	/*
 	 * Initialise the present map, which describes the set of CPUs
 	 * actually populated at the present time.
 	 */
-	cpus = of_find_node_by_path("/cpus");
-	for_each_child_of_node(cpus, cpu) {
-		if (of_property_read_u32(cpu, "reg", &cpu_id)) {
-			pr_warn("%s missing reg property", cpu->full_name);
-			continue;
-		}
-
-		if (cpu_id >= max_cpus)
-			continue;
-
-		set_cpu_present(cpu_id, true);
+	for_each_possible_cpu(cpu) {
+		if (cpu < max_cpus)
+			set_cpu_present(cpu, true);
 	}
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-09  9:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 14:28 [PATCH v2] Use devicetree to determine present cpus (v2) Jan Henrik Weinstock
2021-02-08 14:28 ` [OpenRISC] " Jan Henrik Weinstock
2021-02-08 21:08 ` Stafford Horne
2021-02-08 21:08   ` [OpenRISC] " Stafford Horne
2021-02-09  9:42   ` Jan Henrik Weinstock
2021-02-09  9:42     ` [OpenRISC] " Jan Henrik Weinstock

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.