@@ -24,6 +24,7 @@
#include <linux/vt.h>
#include <linux/mman.h>
#include <linux/elfcore.h>
+#include <linux/pm.h>
#include <linux/reboot.h>
#include <linux/tty.h>
#include <linux/console.h>
@@ -40,12 +41,6 @@
#include "proto.h"
#include "pci_impl.h"
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
#ifdef CONFIG_ALPHA_WTINT
/*
* Sleep the CPU.
@@ -184,6 +179,8 @@ machine_halt(void)
void
machine_power_off(void)
{
+ do_kernel_power_off();
+
common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);
}
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)
void machine_power_off(void)
{
- /* FIXME :: power off ??? */
+ do_kernel_power_off();
machine_halt();
}
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)
/*
* Function pointers to optional machine specific functions
*/
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
@@ -205,8 +203,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
/*
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)
/*
* Function pointers to optional machine specific functions
*/
-void (*pm_power_off)(void);
-EXPORT_SYMBOL_GPL(pm_power_off);
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
@@ -129,8 +127,7 @@ void machine_power_off(void)
{
local_irq_disable();
smp_send_stop();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
/*
@@ -23,9 +23,6 @@
#include <mach/pm.h>
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
/*
* This file handles the architecture-dependent parts of process handling..
*/
@@ -48,8 +45,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
void machine_restart(char *cmd)
@@ -39,9 +39,6 @@ int nr_l1stack_tasks;
void *l1_stack_base;
unsigned long l1_stack_len;
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
/*
* The idle loop on BFIN
*/
@@ -7,6 +7,7 @@
*/
#include <linux/interrupt.h>
+#include <linux/pm.h>
#include <asm/bfin-global.h>
#include <asm/reboot.h>
#include <asm/bfrom.h>
@@ -106,6 +107,7 @@ void machine_halt(void)
__attribute__((weak))
void native_machine_power_off(void)
{
+ do_kernel_power_off();
idle_with_irq_disabled();
}
@@ -27,12 +27,6 @@ void (*c6x_halt)(void);
extern asmlinkage void ret_from_fork(void);
extern asmlinkage void ret_from_kernel_thread(void);
-/*
- * power off function, if any
- */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
void arch_cpu_idle(void)
{
unsigned long tmp;
@@ -73,8 +67,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
halt_loop();
}
@@ -31,9 +31,6 @@
extern void default_idle(void);
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
void arch_cpu_idle(void)
{
default_idle();
@@ -60,6 +57,7 @@ void machine_halt(void)
void machine_power_off(void)
{
+ do_kernel_power_off();
}
/*
@@ -42,9 +42,6 @@ asmlinkage void ret_from_kernel_thread(void);
#include <asm/pgalloc.h>
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
static void core_sleep_idle(void)
{
#ifdef LED_DEBUG_SLEEP
@@ -107,6 +104,8 @@ void machine_power_off(void)
gdbstub_exit(0);
#endif
+ do_kernel_power_off();
+
for (;;);
}
@@ -16,11 +16,13 @@
* 02110-1301, USA.
*/
+#include <linux/pm.h>
#include <linux/smp.h>
#include <asm/hexagon_vm.h>
void machine_power_off(void)
{
+ do_kernel_power_off();
smp_send_stop();
__vmstop();
}
@@ -32,6 +34,3 @@ void machine_halt(void)
void machine_restart(char *cmd)
{
}
-
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
@@ -57,8 +57,6 @@ void (*ia64_mark_idle)(int);
unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;
EXPORT_SYMBOL(boot_option_idle_override);
-void (*pm_power_off) (void);
-EXPORT_SYMBOL(pm_power_off);
void
ia64_do_show_stack (struct unw_frame_info *info, void *arg)
@@ -675,8 +673,7 @@ machine_halt (void)
void
machine_power_off (void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
machine_halt();
}
@@ -23,6 +23,7 @@
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/pm.h>
#include <linux/ptrace.h>
#include <linux/unistd.h>
#include <linux/hardirq.h>
@@ -44,9 +45,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
return tsk->thread.lr;
}
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
void machine_restart(char *__unused)
{
#if defined(CONFIG_PLAT_MAPPI3)
@@ -67,7 +65,9 @@ void machine_halt(void)
void machine_power_off(void)
{
- /* M32R_FIXME */
+ do_kernel_power_off();
+ for (;;)
+ ;
}
void show_regs(struct pt_regs * regs)
@@ -78,14 +78,10 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
for (;;);
}
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
void show_regs(struct pt_regs * regs)
{
printk("\n");
@@ -67,9 +67,6 @@ void arch_cpu_idle_dead(void)
}
#endif
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
void (*soc_restart)(char *cmd);
void (*soc_halt)(void);
@@ -90,8 +87,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
smp_send_stop();
hard_processor_halt(HALT_OK);
}
@@ -44,9 +44,6 @@ void show_regs(struct pt_regs *regs)
regs->msr, regs->ear, regs->esr, regs->fsr);
}
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
void flush_thread(void)
{
}
@@ -103,6 +103,7 @@ void machine_halt(void)
void machine_power_off(void)
{
pr_notice("Machine power off...\n");
+ do_kernel_power_off();
while (1)
;
}
@@ -21,9 +21,6 @@
*/
void (*_machine_restart)(char *command);
void (*_machine_halt)(void);
-void (*pm_power_off)(void);
-
-EXPORT_SYMBOL(pm_power_off);
void machine_restart(char *command)
{
@@ -39,6 +36,5 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
@@ -20,6 +20,7 @@
#include <linux/user.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
+#include <linux/pm.h>
#include <linux/reboot.h>
#include <linux/percpu.h>
#include <linux/err.h>
@@ -45,12 +46,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
}
/*
- * power off function, if any
- */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
-/*
* On SMP it's slightly faster (but much more power-consuming!)
* to poll the ->work.need_resched flag instead of waiting for the
* cross-CPU IPI to arrive. Use this option with caution.
@@ -93,6 +88,7 @@ void machine_power_off(void)
#ifdef CONFIG_KERNEL_DEBUGGER
gdbstub_exit(0);
#endif
+ do_kernel_power_off();
}
void show_regs(struct pt_regs *regs)
@@ -25,6 +25,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mm.h>
+#include <linux/pm.h>
#include <linux/stddef.h>
#include <linux/unistd.h>
#include <linux/ptrace.h>
@@ -51,7 +52,7 @@
*/
struct thread_info *current_thread_info_set[NR_CPUS] = { &init_thread_info, };
-void machine_restart(void)
+void machine_restart(char *cmd)
{
printk(KERN_INFO "*** MACHINE RESTART ***\n");
__asm__("l.nop 1");
@@ -72,11 +73,12 @@ void machine_halt(void)
void machine_power_off(void)
{
printk(KERN_INFO "*** MACHINE POWER OFF ***\n");
+
+ do_kernel_power_off();
+
__asm__("l.nop 1");
}
-void (*pm_power_off) (void) = machine_power_off;
-
/*
* When a process does an "exec", machine state like FPU and debug
* registers need to be reset. This is a hook function for that.
@@ -41,6 +41,7 @@
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/personality.h>
+#include <linux/pm.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/slab.h>
@@ -133,7 +134,9 @@ void machine_power_off(void)
pdc_soft_power_button(0);
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
-
+
+ do_kernel_power_off();
+
/* It seems we have no way to power the system off via
* software. The user has to press the button himself. */
@@ -141,9 +144,6 @@ void machine_power_off(void)
"Please power this system off now.");
}
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
/*
* Free current thread data structures etc..
*/
@@ -139,8 +139,7 @@ void machine_restart(char *cmd)
void machine_power_off(void)
{
machine_shutdown();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
#ifdef CONFIG_SMP
smp_send_stop();
#endif
@@ -151,9 +150,6 @@ void machine_power_off(void)
/* Used by the G5 thermal driver */
EXPORT_SYMBOL_GPL(machine_power_off);
-void (*pm_power_off)(void);
-EXPORT_SYMBOL_GPL(pm_power_off);
-
void machine_halt(void)
{
machine_shutdown();
@@ -981,8 +981,7 @@ static void bootcmds(void)
else if (cmd == 'h')
ppc_md.halt();
else if (cmd == 'p')
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
static int cpu_cmd(void)
@@ -263,13 +263,9 @@ void machine_power_off(void)
*/
console_unblank();
_machine_power_off();
-}
-/*
- * Dummy power off function.
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL_GPL(pm_power_off);
+ do_kernel_power_off();
+}
static int __init early_parse_mem(char *p)
{
@@ -29,9 +29,6 @@
#include <linux/pm.h>
#include <linux/rcupdate.h>
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
/* If or when software machine-restart is implemented, add code here. */
void machine_restart(char *command) {}
@@ -39,7 +36,10 @@ void machine_restart(char *command) {}
void machine_halt(void) {}
/* If or when software machine-power-off is implemented, add code here. */
-void machine_power_off(void) {}
+void machine_power_off(void)
+{
+ do_kernel_power_off();
+}
void ret_from_fork(void);
void ret_from_kernel_thread(void);
@@ -11,9 +11,6 @@
#include <asm/tlbflush.h>
#include <asm/traps.h>
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
#ifdef CONFIG_SUPERH32
static void watchdog_trigger_immediate(void)
{
@@ -51,8 +48,7 @@ static void native_machine_shutdown(void)
static void native_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
static void native_machine_halt(void)
@@ -48,14 +48,6 @@
*/
void (*sparc_idle)(void);
-/*
- * Power-off handler instantiation for pm.h compliance
- * This is done via auxio, but could be used as a fallback
- * handler when auxio is not present-- unused for now...
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
/*
* sysctl - toggle power-off restriction for serial console
* systems in machine_power_off()
@@ -112,6 +104,8 @@ void machine_power_off(void)
sbus_writeb(power_register, auxio_power_register);
}
+ do_kernel_power_off();
+
machine_halt();
}
@@ -16,17 +16,13 @@
*/
int scons_pwroff = 1;
-/* This isn't actually used, it exists merely to satisfy the
- * reference in kernel/sys.c
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
void machine_power_off(void)
{
if (strcmp(of_console_device->type, "serial") || scons_pwroff)
prom_halt_power_off();
+ do_kernel_power_off();
+
prom_halt();
}
@@ -36,6 +36,9 @@ void machine_power_off(void)
{
arch_local_irq_disable_all();
smp_send_stop();
+
+ do_kernel_power_off();
+
hv_power_off();
}
@@ -45,7 +48,3 @@ void machine_restart(char *cmd)
smp_send_stop();
hv_restart((HV_VirtAddr) "vmlinux", (HV_VirtAddr) cmd);
}
-
-/* No interesting distinction to be made here. */
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
@@ -11,8 +11,6 @@
#include <os.h>
#include <skas.h>
-void (*pm_power_off)(void);
-
static void kill_off_processes(void)
{
if (proc_mm)
@@ -56,16 +56,9 @@ void machine_halt(void)
gpio_set_value(GPO_SOFT_OFF, 0);
}
-/*
- * Function pointers to optional machine specific functions
- */
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
machine_halt();
}
@@ -30,12 +30,6 @@
#include <asm/x86_init.h>
#include <asm/efi.h>
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
static const struct desc_ptr no_idt = {};
/*
@@ -647,11 +641,12 @@ static void native_machine_halt(void)
static void native_machine_power_off(void)
{
- if (pm_power_off) {
+ if (have_kernel_power_off()) {
if (!reboot_force)
machine_shutdown();
- pm_power_off();
+ do_kernel_power_off();
}
+
/* A fallback in case there is no PM info available */
tboot_shutdown(TB_SHUTDOWN_HALT);
}
@@ -1320,8 +1320,7 @@ static void xen_machine_halt(void)
static void xen_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
xen_reboot(SHUTDOWN_poweroff);
}
@@ -49,10 +49,6 @@ extern void ret_from_kernel_thread(void);
struct task_struct *current_set[NR_CPUS] = {&init_task, };
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
-
#if XTENSA_HAVE_COPROCESSORS
void coprocessor_release_all(struct thread_info *ti)
@@ -95,8 +95,7 @@ static void process_shutdown(void)
/* send kill signal */
if (kill_cad_pid(SIGINT, 1)) {
/* just in case killing init process failed */
- if (pm_power_off)
- pm_power_off();
+ kernel_power_off();
}
}
}
@@ -23,6 +23,12 @@
#include <linux/types.h>
/*
+ * If set, calling this function will power off the system immediately.
+ */
+void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
+
+/*
* List of handlers for kernel code which wants to be called
* to power off the system.
*/
@@ -272,6 +278,9 @@ void do_kernel_power_off(void)
* that risk.
*/
+ if (pm_power_off)
+ pm_power_off();
+
p = rcu_dereference_raw(power_off_handler_list);
while (p) {
next_p = rcu_dereference_raw(p->next);
@@ -306,9 +306,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
return ret;
/* Instead of trying to make the power_off code look like
- * halt when pm_power_off is not set do it the easy way.
+ * halt when no power-off handler exists do it the easy way.
*/
- if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
+ if (cmd == LINUX_REBOOT_CMD_POWER_OFF && !have_kernel_power_off())
cmd = LINUX_REBOOT_CMD_HALT;
mutex_lock(&reboot_mutex);