[PATCH] C99 designated initializers for arch/sh
[linux-2.6/history.git] / kernel / cpu.c
bloba155998dbe3ec627509bcb246818d5ecdaf9f7a3
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 <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)
31 int ret;
33 if ((ret = down_interruptible(&cpucontrol)) != 0)
34 return ret;
36 if (cpu_online(cpu)) {
37 ret = -EINVAL;
38 goto out;
41 /* Arch-specific enabling code. */
42 ret = __cpu_up(cpu);
43 if (ret != 0) goto out;
44 if (!cpu_online(cpu))
45 BUG();
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);
51 out:
52 up(&cpucontrol);
53 return ret;