Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] make smp_prepare_cpu to a weak function

I really wish smp_prepare_cpu() would disappear eventually. In the interim
this is ideally a weak function, so we dont end up changing several places
to define this dummy in headers.

Today since the dummy declaration is done only in drivers/base/cpu.c but
the function is called in kernel/power/smp.c i get undefined reference in
my cpu hotplug code for x86_64 under development.

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Ashok Raj and committed by
Linus Torvalds
52a119fe e1367daf

+6 -7
+5 -4
drivers/base/cpu.c
··· 16 16 EXPORT_SYMBOL(cpu_sysdev_class); 17 17 18 18 #ifdef CONFIG_HOTPLUG_CPU 19 - #ifndef __HAVE_ARCH_SMP_PREPARE_CPU 20 - #define smp_prepare_cpu(cpu) (0) 21 - #endif 19 + int __attribute__((weak)) smp_prepare_cpu (int cpu) 20 + { 21 + return 0; 22 + } 22 23 23 24 static ssize_t show_online(struct sys_device *dev, char *buf) 24 25 { ··· 42 41 break; 43 42 case '1': 44 43 ret = smp_prepare_cpu(cpu->sysdev.id); 45 - if (ret == 0) 44 + if (!ret) 46 45 ret = cpu_up(cpu->sysdev.id); 47 46 break; 48 47 default:
-3
include/asm-i386/smp.h
··· 51 51 #ifdef CONFIG_HOTPLUG_CPU 52 52 extern void cpu_exit_clear(void); 53 53 extern void cpu_uninit(void); 54 - 55 - #define __HAVE_ARCH_SMP_PREPARE_CPU 56 - extern int smp_prepare_cpu(int cpu); 57 54 #endif 58 55 59 56 /*
+1
include/linux/cpu.h
··· 69 69 register_cpu_notifier(&fn##_nb); \ 70 70 } 71 71 int cpu_down(unsigned int cpu); 72 + extern int __attribute__((weak)) smp_prepare_cpu(int cpu); 72 73 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 73 74 #else 74 75 #define lock_cpu_hotplug() do { } while (0)