drivers: base: add arch_cpu_is_hotpluggable()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 21 Nov 2023 13:44:36 +0000 (13:44 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Dec 2023 03:41:48 +0000 (12:41 +0900)
The differences between architecture specific implementations of
arch_register_cpu() are down to whether the CPU is hotpluggable or not.
Rather than overriding the weak version of arch_register_cpu(), provide
a function that can be used to provide this detail instead.

Reviewed-by: Shaoqin Huang <shahuang@redhat.com>
Signed-off-by: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/E1r5R3M-00CszH-6r@rmk-PC.armlinux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/cpu.c
include/linux/cpu.h

index 58bb86091b349164a8d190c8f8e9207d40cd69a8..221ffbeb1c9becd9a84cb24a0144560f0debb444 100644 (file)
@@ -527,9 +527,18 @@ EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
 #ifdef CONFIG_GENERIC_CPU_DEVICES
 DEFINE_PER_CPU(struct cpu, cpu_devices);
 
+bool __weak arch_cpu_is_hotpluggable(int cpu)
+{
+       return false;
+}
+
 int __weak arch_register_cpu(int cpu)
 {
-       return register_cpu(&per_cpu(cpu_devices, cpu), 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
index 1e982d63eae8c6935eb502427cd0a37edb861dc4..dcb89c9871640f0a92c85c5f16d94a8e199c3a23 100644 (file)
@@ -80,6 +80,7 @@ extern __printf(4, 5)
 struct device *cpu_device_create(struct device *parent, void *drvdata,
                                 const struct attribute_group **groups,
                                 const char *fmt, ...);
+extern bool arch_cpu_is_hotpluggable(int cpu);
 extern int arch_register_cpu(int cpu);
 extern void arch_unregister_cpu(int cpu);
 #ifdef CONFIG_HOTPLUG_CPU