Merge tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / drivers / base / cpu.c
index 548491d..47de0f1 100644 (file)
@@ -525,19 +525,42 @@ bool cpu_is_hotpluggable(unsigned int cpu)
 EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
 
 #ifdef CONFIG_GENERIC_CPU_DEVICES
-static DEFINE_PER_CPU(struct cpu, cpu_devices);
-#endif
+DEFINE_PER_CPU(struct cpu, cpu_devices);
+
+bool __weak arch_cpu_is_hotpluggable(int cpu)
+{
+       return false;
+}
+
+int __weak arch_register_cpu(int cpu)
+{
+       struct cpu *c = &per_cpu(cpu_devices, cpu);
+
+       c->hotpluggable = arch_cpu_is_hotpluggable(cpu);
+
+       return register_cpu(c, cpu);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+void __weak arch_unregister_cpu(int num)
+{
+       unregister_cpu(&per_cpu(cpu_devices, num));
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+#endif /* CONFIG_GENERIC_CPU_DEVICES */
 
 static void __init cpu_dev_register_generic(void)
 {
-#ifdef CONFIG_GENERIC_CPU_DEVICES
-       int i;
+       int i, ret;
 
-       for_each_possible_cpu(i) {
-               if (register_cpu(&per_cpu(cpu_devices, i), i))
-                       panic("Failed to register CPU device");
+       if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES))
+               return;
+
+       for_each_present_cpu(i) {
+               ret = arch_register_cpu(i);
+               if (ret)
+                       pr_warn("register_cpu %d failed (%d)\n", i, ret);
        }
-#endif
 }
 
 #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES