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
)
32 void *hcpu
= (void *)(long)cpu
;
34 if ((ret
= down_interruptible(&cpucontrol
)) != 0)
37 if (cpu_online(cpu
)) {
41 ret
= notifier_call_chain(&cpu_chain
, CPU_UP_PREPARE
, hcpu
);
42 if (ret
== NOTIFY_BAD
) {
43 printk("%s: attempt to bring up CPU %u failed\n",
49 /* Arch-specific enabling code. */
56 /* Now call notifier in preparation. */
57 printk("CPU %u IS NOW UP!\n", cpu
);
58 notifier_call_chain(&cpu_chain
, CPU_ONLINE
, hcpu
);
62 notifier_call_chain(&cpu_chain
, CPU_UP_CANCELED
, hcpu
);