<div dir="ltr">Acked-by: Lennox Wu <<a href="mailto:lennox.wu@gmail.com">lennox.wu@gmail.com</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-21 12:12 GMT+08:00 Guenter Roeck <span dir="ltr"><<a href="mailto:linux@roeck-us.net" target="_blank">linux@roeck-us.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">pm_power_off is defined for all architectures. Move it to common code.<br>
<br>
Have all architectures call do_kernel_power_off instead of pm_power_off.<br>
Some architectures point pm_power_off to machine_power_off. For those,<br>
call do_kernel_power_off from machine_power_off instead.<br>
<br>
Acked-by: David Vrabel <<a href="mailto:david.vrabel@citrix.com">david.vrabel@citrix.com</a>><br>
Acked-by: Geert Uytterhoeven <<a href="mailto:geert@linux-m68k.org">geert@linux-m68k.org</a>><br>
Acked-by: Hirokazu Takata <<a href="mailto:takata@linux-m32r.org">takata@linux-m32r.org</a>><br>
Acked-by: Jesper Nilsson <<a href="mailto:jesper.nilsson@axis.com">jesper.nilsson@axis.com</a>><br>
Acked-by: Max Filippov <<a href="mailto:jcmvbkbc@gmail.com">jcmvbkbc@gmail.com</a>><br>
Acked-by: Rafael J. Wysocki <<a href="mailto:rjw@rjwysocki.net">rjw@rjwysocki.net</a>><br>
Acked-by: Richard Weinberger <<a href="mailto:richard@nod.at">richard@nod.at</a>><br>
Acked-by: Xuetao Guan <<a href="mailto:gxt@mprc.pku.edu.cn">gxt@mprc.pku.edu.cn</a>><br>
Signed-off-by: Guenter Roeck <<a href="mailto:linux@roeck-us.net">linux@roeck-us.net</a>><br>
---<br>
v2:<br>
- do_kernel_poweroff -> do_kernel_power_off<br>
- have_kernel_poweroff -> have_kernel_power_off<br>
<br>
 arch/alpha/kernel/process.c        |  9 +++------<br>
 arch/arc/kernel/reset.c            |  5 +----<br>
 arch/arm/kernel/process.c          |  5 +----<br>
 arch/arm64/kernel/process.c        |  5 +----<br>
 arch/avr32/kernel/process.c        |  6 +-----<br>
 arch/blackfin/kernel/process.c     |  3 ---<br>
 arch/blackfin/kernel/reboot.c      |  2 ++<br>
 arch/c6x/kernel/process.c          |  9 +--------<br>
 arch/cris/kernel/process.c         |  4 +---<br>
 arch/frv/kernel/process.c          |  5 ++---<br>
 arch/hexagon/kernel/reset.c        |  5 ++---<br>
 arch/ia64/kernel/process.c         |  5 +----<br>
 arch/m32r/kernel/process.c         |  8 ++++----<br>
 arch/m68k/kernel/process.c         |  6 +-----<br>
 arch/metag/kernel/process.c        |  6 +-----<br>
 arch/microblaze/kernel/process.c   |  3 ---<br>
 arch/microblaze/kernel/reset.c     |  1 +<br>
 arch/mips/kernel/reset.c           |  6 +-----<br>
 arch/mn10300/kernel/process.c      |  8 ++------<br>
 arch/openrisc/kernel/process.c     |  8 +++++---<br>
 arch/parisc/kernel/process.c       |  8 ++++----<br>
 arch/powerpc/kernel/setup-common.c |  6 +++---<br>
 arch/s390/kernel/setup.c           |  8 ++------<br>
 arch/score/kernel/process.c        |  8 ++++----<br>
 arch/sh/kernel/reboot.c            |  6 +-----<br>
 arch/sparc/kernel/process_32.c     | 10 ++--------<br>
 arch/sparc/kernel/reboot.c         |  8 ++------<br>
 arch/tile/kernel/reboot.c          |  7 +++----<br>
 arch/um/kernel/reboot.c            |  2 --<br>
 arch/unicore32/kernel/process.c    |  9 +--------<br>
 arch/x86/kernel/reboot.c           | 11 +++--------<br>
 arch/x86/xen/enlighten.c           |  3 +--<br>
 arch/xtensa/kernel/process.c       |  4 ----<br>
 drivers/parisc/power.c             |  3 +--<br>
 kernel/power/poweroff_handler.c    |  8 ++++++++<br>
 kernel/reboot.c                    |  4 ++--<br>
 36 files changed, 68 insertions(+), 146 deletions(-)<br>
<br>
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c<br>
index 1941a07..81c43f8 100644<br>
--- a/arch/alpha/kernel/process.c<br>
+++ b/arch/alpha/kernel/process.c<br>
@@ -24,6 +24,7 @@<br>
 #include <linux/vt.h><br>
 #include <linux/mman.h><br>
 #include <linux/elfcore.h><br>
+#include <linux/pm.h><br>
 #include <linux/reboot.h><br>
 #include <linux/tty.h><br>
 #include <linux/console.h><br>
@@ -40,12 +41,6 @@<br>
 #include "proto.h"<br>
 #include "pci_impl.h"<br>
<br>
-/*<br>
- * Power off function, if any<br>
- */<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 #ifdef CONFIG_ALPHA_WTINT<br>
 /*<br>
  * Sleep the CPU.<br>
@@ -184,6 +179,8 @@ machine_halt(void)<br>
 void<br>
 machine_power_off(void)<br>
 {<br>
+       do_kernel_power_off();<br>
+<br>
        common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);<br>
 }<br>
<br>
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c<br>
index 2768fa1..0758d9d 100644<br>
--- a/arch/arc/kernel/reset.c<br>
+++ b/arch/arc/kernel/reset.c<br>
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       /* FIXME ::  power off ??? */<br>
+       do_kernel_power_off();<br>
        machine_halt();<br>
 }<br>
-<br>
-void (*pm_power_off) (void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c<br>
index fe972a2..aa3f656 100644<br>
--- a/arch/arm/kernel/process.c<br>
+++ b/arch/arm/kernel/process.c<br>
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)<br>
 /*<br>
  * Function pointers to optional machine specific functions<br>
  */<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
<br>
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);<br>
<br>
@@ -205,8 +203,7 @@ void machine_power_off(void)<br>
        local_irq_disable();<br>
        smp_send_stop();<br>
<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 /*<br>
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c<br>
index c3065db..46a483a 100644<br>
--- a/arch/arm64/kernel/process.c<br>
+++ b/arch/arm64/kernel/process.c<br>
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)<br>
 /*<br>
  * Function pointers to optional machine specific functions<br>
  */<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL_GPL(pm_power_off);<br>
<br>
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);<br>
<br>
@@ -129,8 +127,7 @@ void machine_power_off(void)<br>
 {<br>
        local_irq_disable();<br>
        smp_send_stop();<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 /*<br>
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c<br>
index 42a53e74..529c1f6 100644<br>
--- a/arch/avr32/kernel/process.c<br>
+++ b/arch/avr32/kernel/process.c<br>
@@ -23,9 +23,6 @@<br>
<br>
 #include <mach/pm.h><br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 /*<br>
  * This file handles the architecture-dependent parts of process handling..<br>
  */<br>
@@ -48,8 +45,7 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 void machine_restart(char *cmd)<br>
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c<br>
index 4aa5545..812dd83 100644<br>
--- a/arch/blackfin/kernel/process.c<br>
+++ b/arch/blackfin/kernel/process.c<br>
@@ -39,9 +39,6 @@ int nr_l1stack_tasks;<br>
 void *l1_stack_base;<br>
 unsigned long l1_stack_len;<br>
<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 /*<br>
  * The idle loop on BFIN<br>
  */<br>
diff --git a/arch/blackfin/kernel/reboot.c b/arch/blackfin/kernel/reboot.c<br>
index c4f50a3..387d610 100644<br>
--- a/arch/blackfin/kernel/reboot.c<br>
+++ b/arch/blackfin/kernel/reboot.c<br>
@@ -7,6 +7,7 @@<br>
  */<br>
<br>
 #include <linux/interrupt.h><br>
+#include <linux/pm.h><br>
 #include <asm/bfin-global.h><br>
 #include <asm/reboot.h><br>
 #include <asm/bfrom.h><br>
@@ -106,6 +107,7 @@ void machine_halt(void)<br>
 __attribute__((weak))<br>
 void native_machine_power_off(void)<br>
 {<br>
+       do_kernel_power_off();<br>
        idle_with_irq_disabled();<br>
 }<br>
<br>
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c<br>
index 57d2ea8..edf7e5a 100644<br>
--- a/arch/c6x/kernel/process.c<br>
+++ b/arch/c6x/kernel/process.c<br>
@@ -27,12 +27,6 @@ void (*c6x_halt)(void);<br>
 extern asmlinkage void ret_from_fork(void);<br>
 extern asmlinkage void ret_from_kernel_thread(void);<br>
<br>
-/*<br>
- * power off function, if any<br>
- */<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void arch_cpu_idle(void)<br>
 {<br>
        unsigned long tmp;<br>
@@ -73,8 +67,7 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        halt_loop();<br>
 }<br>
<br>
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c<br>
index b78498e..9ebd76b 100644<br>
--- a/arch/cris/kernel/process.c<br>
+++ b/arch/cris/kernel/process.c<br>
@@ -31,9 +31,6 @@<br>
<br>
 extern void default_idle(void);<br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void arch_cpu_idle(void)<br>
 {<br>
        default_idle();<br>
@@ -60,6 +57,7 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 /*<br>
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c<br>
index 5d40aeb77..502dabb 100644<br>
--- a/arch/frv/kernel/process.c<br>
+++ b/arch/frv/kernel/process.c<br>
@@ -42,9 +42,6 @@ asmlinkage void ret_from_kernel_thread(void);<br>
<br>
 #include <asm/pgalloc.h><br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 static void core_sleep_idle(void)<br>
 {<br>
 #ifdef LED_DEBUG_SLEEP<br>
@@ -107,6 +104,8 @@ void machine_power_off(void)<br>
        gdbstub_exit(0);<br>
 #endif<br>
<br>
+       do_kernel_power_off();<br>
+<br>
        for (;;);<br>
 }<br>
<br>
diff --git a/arch/hexagon/kernel/reset.c b/arch/hexagon/kernel/reset.c<br>
index 76483c1..6f607b6 100644<br>
--- a/arch/hexagon/kernel/reset.c<br>
+++ b/arch/hexagon/kernel/reset.c<br>
@@ -16,11 +16,13 @@<br>
  * 02110-1301, USA.<br>
  */<br>
<br>
+#include <linux/pm.h><br>
 #include <linux/smp.h><br>
 #include <asm/hexagon_vm.h><br>
<br>
 void machine_power_off(void)<br>
 {<br>
+       do_kernel_power_off();<br>
        smp_send_stop();<br>
        __vmstop();<br>
 }<br>
@@ -32,6 +34,3 @@ void machine_halt(void)<br>
 void machine_restart(char *cmd)<br>
 {<br>
 }<br>
-<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c<br>
index b515149..88121a2 100644<br>
--- a/arch/ia64/kernel/process.c<br>
+++ b/arch/ia64/kernel/process.c<br>
@@ -57,8 +57,6 @@ void (*ia64_mark_idle)(int);<br>
<br>
 unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;<br>
 EXPORT_SYMBOL(boot_option_idle_override);<br>
-void (*pm_power_off) (void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
<br>
 void<br>
 ia64_do_show_stack (struct unw_frame_info *info, void *arg)<br>
@@ -675,8 +673,7 @@ machine_halt (void)<br>
 void<br>
 machine_power_off (void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        machine_halt();<br>
 }<br>
<br>
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c<br>
index e69221d..65a037e 100644<br>
--- a/arch/m32r/kernel/process.c<br>
+++ b/arch/m32r/kernel/process.c<br>
@@ -23,6 +23,7 @@<br>
 #include <linux/fs.h><br>
 #include <linux/slab.h><br>
 #include <linux/module.h><br>
+#include <linux/pm.h><br>
 #include <linux/ptrace.h><br>
 #include <linux/unistd.h><br>
 #include <linux/hardirq.h><br>
@@ -44,9 +45,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)<br>
        return tsk-><a href="http://thread.lr" target="_blank">thread.lr</a>;<br>
 }<br>
<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void machine_restart(char *__unused)<br>
 {<br>
 #if defined(CONFIG_PLAT_MAPPI3)<br>
@@ -67,7 +65,9 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       /* M32R_FIXME */<br>
+       do_kernel_power_off();<br>
+       for (;;)<br>
+               ;<br>
 }<br>
<br>
 void show_regs(struct pt_regs * regs)<br>
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c<br>
index afe3d6e..bbc0a63 100644<br>
--- a/arch/m68k/kernel/process.c<br>
+++ b/arch/m68k/kernel/process.c<br>
@@ -78,14 +78,10 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        for (;;);<br>
 }<br>
<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void show_regs(struct pt_regs * regs)<br>
 {<br>
        printk("\n");<br>
diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c<br>
index 483dff9..8d95773 100644<br>
--- a/arch/metag/kernel/process.c<br>
+++ b/arch/metag/kernel/process.c<br>
@@ -67,9 +67,6 @@ void arch_cpu_idle_dead(void)<br>
 }<br>
 #endif<br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void (*soc_restart)(char *cmd);<br>
 void (*soc_halt)(void);<br>
<br>
@@ -90,8 +87,7 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        smp_send_stop();<br>
        hard_processor_halt(HALT_OK);<br>
 }<br>
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c<br>
index b2dd371..0ebca36 100644<br>
--- a/arch/microblaze/kernel/process.c<br>
+++ b/arch/microblaze/kernel/process.c<br>
@@ -44,9 +44,6 @@ void show_regs(struct pt_regs *regs)<br>
                                regs->msr, regs->ear, regs->esr, regs->fsr);<br>
 }<br>
<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void flush_thread(void)<br>
 {<br>
 }<br>
diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c<br>
index fbe58c6..2c6b32c 100644<br>
--- a/arch/microblaze/kernel/reset.c<br>
+++ b/arch/microblaze/kernel/reset.c<br>
@@ -103,6 +103,7 @@ void machine_halt(void)<br>
 void machine_power_off(void)<br>
 {<br>
        pr_notice("Machine power off...\n");<br>
+       do_kernel_power_off();<br>
        while (1)<br>
                ;<br>
 }<br>
diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c<br>
index 07fc524..09e74d2 100644<br>
--- a/arch/mips/kernel/reset.c<br>
+++ b/arch/mips/kernel/reset.c<br>
@@ -21,9 +21,6 @@<br>
  */<br>
 void (*_machine_restart)(char *command);<br>
 void (*_machine_halt)(void);<br>
-void (*pm_power_off)(void);<br>
-<br>
-EXPORT_SYMBOL(pm_power_off);<br>
<br>
 void machine_restart(char *command)<br>
 {<br>
@@ -39,6 +36,5 @@ void machine_halt(void)<br>
<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
 }<br>
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c<br>
index 3707da5..c78b2eb 100644<br>
--- a/arch/mn10300/kernel/process.c<br>
+++ b/arch/mn10300/kernel/process.c<br>
@@ -20,6 +20,7 @@<br>
 #include <linux/user.h><br>
 #include <linux/interrupt.h><br>
 #include <linux/delay.h><br>
+#include <linux/pm.h><br>
 #include <linux/reboot.h><br>
 #include <linux/percpu.h><br>
 #include <linux/err.h><br>
@@ -45,12 +46,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)<br>
 }<br>
<br>
 /*<br>
- * power off function, if any<br>
- */<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
-/*<br>
  * On SMP it's slightly faster (but much more power-consuming!)<br>
  * to poll the ->work.need_resched flag instead of waiting for the<br>
  * cross-CPU IPI to arrive. Use this option with caution.<br>
@@ -93,6 +88,7 @@ void machine_power_off(void)<br>
 #ifdef CONFIG_KERNEL_DEBUGGER<br>
        gdbstub_exit(0);<br>
 #endif<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 void show_regs(struct pt_regs *regs)<br>
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c<br>
index 386af25..494afd2 100644<br>
--- a/arch/openrisc/kernel/process.c<br>
+++ b/arch/openrisc/kernel/process.c<br>
@@ -25,6 +25,7 @@<br>
 #include <linux/kernel.h><br>
 #include <linux/module.h><br>
 #include <linux/mm.h><br>
+#include <linux/pm.h><br>
 #include <linux/stddef.h><br>
 #include <linux/unistd.h><br>
 #include <linux/ptrace.h><br>
@@ -51,7 +52,7 @@<br>
  */<br>
 struct thread_info *current_thread_info_set[NR_CPUS] = { &init_thread_info, };<br>
<br>
-void machine_restart(void)<br>
+void machine_restart(char *cmd)<br>
 {<br>
        printk(KERN_INFO "*** MACHINE RESTART ***\n");<br>
        __asm__("l.nop 1");<br>
@@ -72,11 +73,12 @@ void machine_halt(void)<br>
 void machine_power_off(void)<br>
 {<br>
        printk(KERN_INFO "*** MACHINE POWER OFF ***\n");<br>
+<br>
+       do_kernel_power_off();<br>
+<br>
        __asm__("l.nop 1");<br>
 }<br>
<br>
-void (*pm_power_off) (void) = machine_power_off;<br>
-<br>
 /*<br>
  * When a process does an "exec", machine state like FPU and debug<br>
  * registers need to be reset.  This is a hook function for that.<br>
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c<br>
index 0bbbf0d..3f5d14a 100644<br>
--- a/arch/parisc/kernel/process.c<br>
+++ b/arch/parisc/kernel/process.c<br>
@@ -41,6 +41,7 @@<br>
 #include <linux/fs.h><br>
 #include <linux/module.h><br>
 #include <linux/personality.h><br>
+#include <linux/pm.h><br>
 #include <linux/ptrace.h><br>
 #include <linux/sched.h><br>
 #include <linux/slab.h><br>
@@ -133,7 +134,9 @@ void machine_power_off(void)<br>
        pdc_soft_power_button(0);<br>
<br>
        pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);<br>
-<br>
+<br>
+       do_kernel_power_off();<br>
+<br>
        /* It seems we have no way to power the system off via<br>
         * software. The user has to press the button himself. */<br>
<br>
@@ -141,9 +144,6 @@ void machine_power_off(void)<br>
               "Please power this system off now.");<br>
 }<br>
<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 /*<br>
  * Free current thread data structures etc..<br>
  */<br>
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c<br>
index 1362cd6..5b7a851 100644<br>
--- a/arch/powerpc/kernel/setup-common.c<br>
+++ b/arch/powerpc/kernel/setup-common.c<br>
@@ -141,6 +141,9 @@ void machine_power_off(void)<br>
        machine_shutdown();<br>
        if (ppc_md.power_off)<br>
                ppc_md.power_off();<br>
+<br>
+       do_kernel_power_off();<br>
+<br>
 #ifdef CONFIG_SMP<br>
        smp_send_stop();<br>
 #endif<br>
@@ -151,9 +154,6 @@ void machine_power_off(void)<br>
 /* Used by the G5 thermal driver */<br>
 EXPORT_SYMBOL_GPL(machine_power_off);<br>
<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL_GPL(pm_power_off);<br>
-<br>
 void machine_halt(void)<br>
 {<br>
        machine_shutdown();<br>
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c<br>
index e80d9ff..267e025 100644<br>
--- a/arch/s390/kernel/setup.c<br>
+++ b/arch/s390/kernel/setup.c<br>
@@ -263,13 +263,9 @@ void machine_power_off(void)<br>
                 */<br>
                console_unblank();<br>
        _machine_power_off();<br>
-}<br>
<br>
-/*<br>
- * Dummy power off function.<br>
- */<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL_GPL(pm_power_off);<br>
+       do_kernel_power_off();<br>
+}<br>
<br>
 static int __init early_parse_mem(char *p)<br>
 {<br>
diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c<br>
index a1519ad3..b76ea67 100644<br>
--- a/arch/score/kernel/process.c<br>
+++ b/arch/score/kernel/process.c<br>
@@ -29,9 +29,6 @@<br>
 #include <linux/pm.h><br>
 #include <linux/rcupdate.h><br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 /* If or when software machine-restart is implemented, add code here. */<br>
 void machine_restart(char *command) {}<br>
<br>
@@ -39,7 +36,10 @@ void machine_restart(char *command) {}<br>
 void machine_halt(void) {}<br>
<br>
 /* If or when software machine-power-off is implemented, add code here. */<br>
-void machine_power_off(void) {}<br>
+void machine_power_off(void)<br>
+{<br>
+       do_kernel_power_off();<br>
+}<br>
<br>
 void ret_from_fork(void);<br>
 void ret_from_kernel_thread(void);<br>
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c<br>
index 04afe5b..065de12 100644<br>
--- a/arch/sh/kernel/reboot.c<br>
+++ b/arch/sh/kernel/reboot.c<br>
@@ -11,9 +11,6 @@<br>
 #include <asm/tlbflush.h><br>
 #include <asm/traps.h><br>
<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 #ifdef CONFIG_SUPERH32<br>
 static void watchdog_trigger_immediate(void)<br>
 {<br>
@@ -51,8 +48,7 @@ static void native_machine_shutdown(void)<br>
<br>
 static void native_machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
 }<br>
<br>
 static void native_machine_halt(void)<br>
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c<br>
index 50e7b62..cb8148a 100644<br>
--- a/arch/sparc/kernel/process_32.c<br>
+++ b/arch/sparc/kernel/process_32.c<br>
@@ -48,14 +48,6 @@<br>
  */<br>
 void (*sparc_idle)(void);<br>
<br>
-/*<br>
- * Power-off handler instantiation for pm.h compliance<br>
- * This is done via auxio, but could be used as a fallback<br>
- * handler when auxio is not present-- unused for now...<br>
- */<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 /*<br>
  * sysctl - toggle power-off restriction for serial console<br>
  * systems in machine_power_off()<br>
@@ -112,6 +104,8 @@ void machine_power_off(void)<br>
                sbus_writeb(power_register, auxio_power_register);<br>
        }<br>
<br>
+       do_kernel_power_off();<br>
+<br>
        machine_halt();<br>
 }<br>
<br>
diff --git a/arch/sparc/kernel/reboot.c b/arch/sparc/kernel/reboot.c<br>
index eba7d91..3c0bb03 100644<br>
--- a/arch/sparc/kernel/reboot.c<br>
+++ b/arch/sparc/kernel/reboot.c<br>
@@ -16,17 +16,13 @@<br>
  */<br>
 int scons_pwroff = 1;<br>
<br>
-/* This isn't actually used, it exists merely to satisfy the<br>
- * reference in kernel/sys.c<br>
- */<br>
-void (*pm_power_off)(void) = machine_power_off;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void machine_power_off(void)<br>
 {<br>
        if (strcmp(of_console_device->type, "serial") || scons_pwroff)<br>
                prom_halt_power_off();<br>
<br>
+       do_kernel_power_off();<br>
+<br>
        prom_halt();<br>
 }<br>
<br>
diff --git a/arch/tile/kernel/reboot.c b/arch/tile/kernel/reboot.c<br>
index 6c5d2c0..8ff4a7f 100644<br>
--- a/arch/tile/kernel/reboot.c<br>
+++ b/arch/tile/kernel/reboot.c<br>
@@ -36,6 +36,9 @@ void machine_power_off(void)<br>
 {<br>
        arch_local_irq_disable_all();<br>
        smp_send_stop();<br>
+<br>
+       do_kernel_power_off();<br>
+<br>
        hv_power_off();<br>
 }<br>
<br>
@@ -45,7 +48,3 @@ void machine_restart(char *cmd)<br>
        smp_send_stop();<br>
        hv_restart((HV_VirtAddr) "vmlinux", (HV_VirtAddr) cmd);<br>
 }<br>
-<br>
-/* No interesting distinction to be made here. */<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c<br>
index ced8903..a82ef28 100644<br>
--- a/arch/um/kernel/reboot.c<br>
+++ b/arch/um/kernel/reboot.c<br>
@@ -11,8 +11,6 @@<br>
 #include <os.h><br>
 #include <skas.h><br>
<br>
-void (*pm_power_off)(void);<br>
-<br>
 static void kill_off_processes(void)<br>
 {<br>
        if (proc_mm)<br>
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c<br>
index b008e99..9490dd5 100644<br>
--- a/arch/unicore32/kernel/process.c<br>
+++ b/arch/unicore32/kernel/process.c<br>
@@ -56,16 +56,9 @@ void machine_halt(void)<br>
        gpio_set_value(GPO_SOFT_OFF, 0);<br>
 }<br>
<br>
-/*<br>
- * Function pointers to optional machine specific functions<br>
- */<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 void machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        machine_halt();<br>
 }<br>
<br>
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c<br>
index 17962e6..5c09e28 100644<br>
--- a/arch/x86/kernel/reboot.c<br>
+++ b/arch/x86/kernel/reboot.c<br>
@@ -30,12 +30,6 @@<br>
 #include <asm/x86_init.h><br>
 #include <asm/efi.h><br>
<br>
-/*<br>
- * Power off function, if any<br>
- */<br>
-void (*pm_power_off)(void);<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
 static const struct desc_ptr no_idt = {};<br>
<br>
 /*<br>
@@ -647,11 +641,12 @@ static void native_machine_halt(void)<br>
<br>
 static void native_machine_power_off(void)<br>
 {<br>
-       if (pm_power_off) {<br>
+       if (have_kernel_power_off()) {<br>
                if (!reboot_force)<br>
                        machine_shutdown();<br>
-               pm_power_off();<br>
+               do_kernel_power_off();<br>
        }<br>
+<br>
        /* A fallback in case there is no PM info available */<br>
        tboot_shutdown(TB_SHUTDOWN_HALT);<br>
 }<br>
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c<br>
index 1a3f044..c2c1d74 100644<br>
--- a/arch/x86/xen/enlighten.c<br>
+++ b/arch/x86/xen/enlighten.c<br>
@@ -1320,8 +1320,7 @@ static void xen_machine_halt(void)<br>
<br>
 static void xen_machine_power_off(void)<br>
 {<br>
-       if (pm_power_off)<br>
-               pm_power_off();<br>
+       do_kernel_power_off();<br>
        xen_reboot(SHUTDOWN_poweroff);<br>
 }<br>
<br>
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c<br>
index 1c85323..c487296 100644<br>
--- a/arch/xtensa/kernel/process.c<br>
+++ b/arch/xtensa/kernel/process.c<br>
@@ -49,10 +49,6 @@ extern void ret_from_kernel_thread(void);<br>
<br>
 struct task_struct *current_set[NR_CPUS] = {&init_task, };<br>
<br>
-void (*pm_power_off)(void) = NULL;<br>
-EXPORT_SYMBOL(pm_power_off);<br>
-<br>
-<br>
 #if XTENSA_HAVE_COPROCESSORS<br>
<br>
 void coprocessor_release_all(struct thread_info *ti)<br>
diff --git a/drivers/parisc/power.c b/drivers/parisc/power.c<br>
index ef31b77..f10cf92 100644<br>
--- a/drivers/parisc/power.c<br>
+++ b/drivers/parisc/power.c<br>
@@ -95,8 +95,7 @@ static void process_shutdown(void)<br>
                /* send kill signal */<br>
                if (kill_cad_pid(SIGINT, 1)) {<br>
                        /* just in case killing init process failed */<br>
-                       if (pm_power_off)<br>
-                               pm_power_off();<br>
+                       kernel_power_off();<br>
                }<br>
        }<br>
 }<br>
diff --git a/kernel/power/poweroff_handler.c b/kernel/power/poweroff_handler.c<br>
index aeb4736..37f0b88 100644<br>
--- a/kernel/power/poweroff_handler.c<br>
+++ b/kernel/power/poweroff_handler.c<br>
@@ -22,6 +22,12 @@<br>
 #include <linux/types.h><br>
<br>
 /*<br>
+ * If set, calling this function will power off the system immediately.<br>
+ */<br>
+void (*pm_power_off)(void);<br>
+EXPORT_SYMBOL(pm_power_off);<br>
+<br>
+/*<br>
  *     Notifier list for kernel code which wants to be called<br>
  *     to power off the system.<br>
  */<br>
@@ -236,6 +242,8 @@ EXPORT_SYMBOL(devm_register_power_off_handler);<br>
 void do_kernel_power_off(void)<br>
 {<br>
        spin_lock(&power_off_handler_lock);<br>
+       if (pm_power_off)<br>
+               pm_power_off();<br>
        raw_notifier_call_chain(&power_off_handler_list, 0, NULL);<br>
        spin_unlock(&power_off_handler_lock);<br>
 }<br>
diff --git a/kernel/reboot.c b/kernel/reboot.c<br>
index 5925f5a..0930851 100644<br>
--- a/kernel/reboot.c<br>
+++ b/kernel/reboot.c<br>
@@ -306,9 +306,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,<br>
                return ret;<br>
<br>
        /* Instead of trying to make the power_off code look like<br>
-        * halt when pm_power_off is not set do it the easy way.<br>
+        * halt when no poweroff handler exists do it the easy way.<br>
         */<br>
-       if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)<br>
+       if (cmd == LINUX_REBOOT_CMD_POWER_OFF && !have_kernel_power_off())<br>
                cmd = LINUX_REBOOT_CMD_HALT;<br>
<br>
        mutex_lock(&reboot_mutex);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
--<br>
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br>
the body of a message to <a href="mailto:majordomo@vger.kernel.org">majordomo@vger.kernel.org</a><br>
More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank">http://vger.kernel.org/majordomo-info.html</a><br>
Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank">http://www.tux.org/lkml/</a><br>
</font></span></blockquote></div><br></div>