2 * (C) 2001 Rusty Russell
3 * This code is licenced under the GPL.
5 #include <linux/proc_fs.h>
7 #include <linux/init.h>
8 #include <linux/notifier.h>
9 #include <linux/sched.h>
10 #include <linux/unistd.h>
11 #include <asm/semaphore.h>
13 /* This protects CPUs going up and down... */
14 DECLARE_MUTEX(cpucontrol
);
16 static struct notifier_block
*cpu_chain
= NULL
;
18 /* Need to know about CPUs going up/down? */
19 int register_cpu_notifier(struct notifier_block
*nb
)
21 return notifier_chain_register(&cpu_chain
, nb
);
24 void unregister_cpu_notifier(struct notifier_block
*nb
)
26 notifier_chain_unregister(&cpu_chain
,nb
);
29 int __devinit
cpu_up(unsigned int cpu
)
33 if ((ret
= down_interruptible(&cpucontrol
)) != 0)
36 if (cpu_online(cpu
)) {
41 /* Arch-specific enabling code. */
43 if (ret
!= 0) goto out
;
47 /* Now call notifier in preparation. */
48 printk("CPU %u IS NOW UP!\n", cpu
);
49 notifier_call_chain(&cpu_chain
, CPU_ONLINE
, (void *)(long)cpu
);