[SCSI] mptfusion: task abort fix's
[pandora-kernel.git] / kernel / cpu.c
index e882c6b..70fbf2e 100644 (file)
 #include <linux/module.h>
 #include <linux/kthread.h>
 #include <linux/stop_machine.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 /* This protects CPUs going up and down... */
-static DECLARE_MUTEX(cpucontrol);
+static DEFINE_MUTEX(cpucontrol);
 
-static struct notifier_block *cpu_chain;
+static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain);
 
 #ifdef CONFIG_HOTPLUG_CPU
 static struct task_struct *lock_cpu_hotplug_owner;
@@ -30,9 +30,9 @@ static int __lock_cpu_hotplug(int interruptible)
 
        if (lock_cpu_hotplug_owner != current) {
                if (interruptible)
-                       ret = down_interruptible(&cpucontrol);
+                       ret = mutex_lock_interruptible(&cpucontrol);
                else
-                       down(&cpucontrol);
+                       mutex_lock(&cpucontrol);
        }
 
        /*
@@ -56,7 +56,7 @@ void unlock_cpu_hotplug(void)
 {
        if (--lock_cpu_hotplug_depth == 0) {
                lock_cpu_hotplug_owner = NULL;
-               up(&cpucontrol);
+               mutex_unlock(&cpucontrol);
        }
 }
 EXPORT_SYMBOL_GPL(unlock_cpu_hotplug);
@@ -69,27 +69,21 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible);
 #endif /* CONFIG_HOTPLUG_CPU */
 
 /* Need to know about CPUs going up/down? */
-int register_cpu_notifier(struct notifier_block *nb)
+int __cpuinit register_cpu_notifier(struct notifier_block *nb)
 {
-       int ret;
-
-       if ((ret = lock_cpu_hotplug_interruptible()) != 0)
-               return ret;
-       ret = notifier_chain_register(&cpu_chain, nb);
-       unlock_cpu_hotplug();
-       return ret;
+       return blocking_notifier_chain_register(&cpu_chain, nb);
 }
+
+#ifdef CONFIG_HOTPLUG_CPU
+
 EXPORT_SYMBOL(register_cpu_notifier);
 
 void unregister_cpu_notifier(struct notifier_block *nb)
 {
-       lock_cpu_hotplug();
-       notifier_chain_unregister(&cpu_chain, nb);
-       unlock_cpu_hotplug();
+       blocking_notifier_chain_unregister(&cpu_chain, nb);
 }
 EXPORT_SYMBOL(unregister_cpu_notifier);
 
-#ifdef CONFIG_HOTPLUG_CPU
 static inline void check_for_tasks(int cpu)
 {
        struct task_struct *p;
@@ -141,7 +135,7 @@ int cpu_down(unsigned int cpu)
                goto out;
        }
 
-       err = notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE,
+       err = blocking_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE,
                                                (void *)(long)cpu);
        if (err == NOTIFY_BAD) {
                printk("%s: attempt to take down CPU %u failed\n",
@@ -159,7 +153,7 @@ int cpu_down(unsigned int cpu)
        p = __stop_machine_run(take_cpu_down, NULL, cpu);
        if (IS_ERR(p)) {
                /* CPU didn't die: tell everyone.  Can't complain. */
-               if (notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED,
+               if (blocking_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED,
                                (void *)(long)cpu) == NOTIFY_BAD)
                        BUG();
 
@@ -182,8 +176,8 @@ int cpu_down(unsigned int cpu)
        put_cpu();
 
        /* CPU is completely dead: tell everyone.  Too late to complain. */
-       if (notifier_call_chain(&cpu_chain, CPU_DEAD, (void *)(long)cpu)
-           == NOTIFY_BAD)
+       if (blocking_notifier_call_chain(&cpu_chain, CPU_DEAD,
+                       (void *)(long)cpu) == NOTIFY_BAD)
                BUG();
 
        check_for_tasks(cpu);
@@ -211,7 +205,7 @@ int __devinit cpu_up(unsigned int cpu)
                goto out;
        }
 
-       ret = notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu);
+       ret = blocking_notifier_call_chain(&cpu_chain, CPU_UP_PREPARE, hcpu);
        if (ret == NOTIFY_BAD) {
                printk("%s: attempt to bring up CPU %u failed\n",
                                __FUNCTION__, cpu);
@@ -223,15 +217,15 @@ int __devinit cpu_up(unsigned int cpu)
        ret = __cpu_up(cpu);
        if (ret != 0)
                goto out_notify;
-       if (!cpu_online(cpu))
-               BUG();
+       BUG_ON(!cpu_online(cpu));
 
        /* Now call notifier in preparation. */
-       notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
+       blocking_notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
 
 out_notify:
        if (ret != 0)
-               notifier_call_chain(&cpu_chain, CPU_UP_CANCELED, hcpu);
+               blocking_notifier_call_chain(&cpu_chain,
+                               CPU_UP_CANCELED, hcpu);
 out:
        unlock_cpu_hotplug();
        return ret;