[PATCH] Fix up 'linux-dvb' maintainers entry
[linux-2.6/history.git] / kernel / cpu.c
blob0652d1871f2fb948d62efee71dcaa637795fa2aa
1 /* CPU control.
2 * (C) 2001 Rusty Russell
3 * This code is licenced under the GPL.
4 */
5 #include <linux/proc_fs.h>
6 #include <linux/smp.h>
7 #include <linux/init.h>
8 #include <linux/notifier.h>
9 #include <linux/sched.h>
10 #include <linux/unistd.h>
11 #include <linux/cpu.h>
12 #include <asm/semaphore.h>
14 /* This protects CPUs going up and down... */
15 DECLARE_MUTEX(cpucontrol);
17 static struct notifier_block *cpu_chain;
19 /* Need to know about CPUs going up/down? */
20 int register_cpu_notifier(struct notifier_block *nb)
22 return notifier_chain_register(&cpu_chain, nb);
25 void unregister_cpu_notifier(struct notifier_block *nb)
27 notifier_chain_unregister(&cpu_chain,nb);
30 int __devinit cpu_up(unsigned int cpu)
32 int ret;
33 void *hcpu = (void *)(long)cpu;
35 if ((ret = down_interruptible(&cpucontrol)) != 0)
36 return ret;
38 if (cpu_online(cpu)) {
39 ret = -EINVAL;
40 goto out;
42 ret = notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu);
43 if (ret == NOTIFY_BAD) {
44 printk("%s: attempt to bring up CPU %u failed\n",
45 __FUNCTION__, cpu);
46 ret = -EINVAL;
47 goto out_notify;
50 /* Arch-specific enabling code. */
51 ret = __cpu_up(cpu);
52 if (ret != 0)
53 goto out_notify;
54 if (!cpu_online(cpu))
55 BUG();
57 /* Now call notifier in preparation. */
58 printk("CPU %u IS NOW UP!\n", cpu);
59 notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
61 out_notify:
62 if (ret != 0)
63 notifier_call_chain(&cpu_chain, CPU_UP_CANCELED, hcpu);
64 out:
65 up(&cpucontrol);
66 return ret;