[PATCH] sysctl: frv: pm remove unnecessary insert_at_head flag
[powerpc.git] / arch / x86_64 / kernel / reboot.c
index d4c45ff..2d67698 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <linux/pm.h>
 #include <asm/io.h>
 #include <asm/kdebug.h>
 #include <asm/delay.h>
@@ -19,6 +20,7 @@
  * Power off function, if any
  */
 void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
 
 static long no_idt[3];
 static enum { 
@@ -77,6 +79,7 @@ static inline void kb_wait(void)
 
 void machine_shutdown(void)
 {
+       unsigned long flags;
        /* Stop the cpus and apics */
 #ifdef CONFIG_SMP
        int reboot_cpu_id;
@@ -98,7 +101,7 @@ void machine_shutdown(void)
        smp_send_stop();
 #endif
 
-       local_irq_disable();
+       local_irq_save(flags);
 
 #ifndef CONFIG_SMP
        disable_local_APIC();
@@ -106,19 +109,13 @@ void machine_shutdown(void)
 
        disable_IO_APIC();
 
-       local_irq_enable();
+       local_irq_restore(flags);
 }
 
-void machine_restart(char * __unused)
+void machine_emergency_restart(void)
 {
        int i;
 
-       printk("machine restart\n");
-
-       if (!reboot_force) {
-               machine_shutdown();
-       }
-       
        /* Tell the BIOS if we want cold or warm reboot */
        *((unsigned short *)__va(0x472)) = reboot_mode;
        
@@ -126,7 +123,7 @@ void machine_restart(char * __unused)
                /* Could also try the reset bit in the Hammer NB */
                switch (reboot_type) { 
                case BOOT_KBD:
-               for (i=0; i<100; i++) {
+               for (i=0; i<10; i++) {
                        kb_wait();
                        udelay(50);
                        outb(0xfe,0x64);         /* pulse reset low */
@@ -143,13 +140,27 @@ void machine_restart(char * __unused)
        }      
 }
 
+void machine_restart(char * __unused)
+{
+       printk("machine restart\n");
+
+       if (!reboot_force) {
+               machine_shutdown();
+       }
+       machine_emergency_restart();
+}
+
 void machine_halt(void)
 {
 }
 
 void machine_power_off(void)
 {
-       if (pm_power_off)
+       if (pm_power_off) {
+               if (!reboot_force) {
+                       machine_shutdown();
+               }
                pm_power_off();
+       }
 }