@@ -43,12 +43,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.
@@ -26,6 +26,3 @@ void machine_power_off(void)
/* FIXME :: power off ??? */
machine_halt();
}
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
@@ -6,6 +6,7 @@
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/reboot.h>
+#include <linux/pm.h>
#include <asm/cacheflush.h>
#include <asm/idmap.h>
@@ -19,8 +20,6 @@ typedef void (*phys_reset_t)(unsigned long, bool);
* Function pointers to optional machine specific functions
*/
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
/*
* A temporary stack to use for CPU reset. This is static so that we
@@ -118,8 +117,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
}
/*
@@ -67,9 +67,6 @@ EXPORT_SYMBOL(__stack_chk_guard);
/*
* 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);
static void noinstr __cpu_do_idle(void)
@@ -172,8 +169,7 @@ void machine_power_off(void)
{
local_irq_disable();
smp_send_stop();
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
}
/*
@@ -15,6 +15,7 @@
#include <linux/reboot.h>
#include <linux/sched/task.h>
#include <linux/sched/task_stack.h>
+#include <linux/pm.h>
#include <asm/syscalls.h>
@@ -25,12 +26,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;
@@ -71,8 +66,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
halt_loop();
}
@@ -2,23 +2,19 @@
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
#include <linux/reboot.h>
-
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
+#include <linux/pm.h>
void machine_power_off(void)
{
local_irq_disable();
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
asm volatile ("bkpt");
}
void machine_halt(void)
{
local_irq_disable();
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
asm volatile ("bkpt");
}
@@ -46,9 +46,6 @@
#include <asm/traps.h>
#include <asm/setup.h>
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);
@@ -19,6 +19,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);
static void
ia64_do_show_stack (struct unw_frame_info *info, void *arg)
@@ -602,8 +600,7 @@ machine_halt (void)
void
machine_power_off (void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off()
machine_halt();
}
@@ -72,9 +72,6 @@ void machine_power_off(void)
for (;;);
}
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
void show_regs(struct pt_regs * regs)
{
pr_info("Format %02x Vector: %04x PC: %08lx Status: %04x %s\n",
@@ -46,9 +46,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)
{
}
@@ -25,9 +25,6 @@
*/
void (*_machine_restart)(char *command);
void (*_machine_halt)(void);
-void (*pm_power_off)(void);
-
-EXPORT_SYMBOL(pm_power_off);
static void machine_hang(void)
{
@@ -114,8 +111,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
#ifdef CONFIG_SMP
preempt_disable();
@@ -12,6 +12,7 @@
#include <asm/fpu.h>
#include <linux/ptrace.h>
#include <linux/reboot.h>
+#include <linux/pm.h>
#if IS_ENABLED(CONFIG_LAZY_FPU)
struct task_struct *last_task_used_math;
@@ -27,9 +28,6 @@ extern inline void arch_reset(char mode)
}
}
-void (*pm_power_off) (void);
-EXPORT_SYMBOL(pm_power_off);
-
static char reboot_mode_nds32 = 'h';
int __init reboot_setup(char *str)
@@ -54,8 +52,7 @@ EXPORT_SYMBOL(machine_halt);
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
}
EXPORT_SYMBOL(machine_power_off);
@@ -28,9 +28,6 @@
asmlinkage void ret_from_fork(void);
asmlinkage void ret_from_kernel_thread(void);
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
void arch_cpu_idle(void)
{
raw_local_irq_enable();
@@ -84,9 +84,6 @@ void arch_cpu_idle(void)
mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME);
}
-void (*pm_power_off) (void) = machine_power_off;
-EXPORT_SYMBOL(pm_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/rcupdate.h>
#include <linux/random.h>
#include <linux/nmi.h>
+#include <linux/pm.h>
#include <asm/io.h>
#include <asm/asm-offsets.h>
@@ -117,9 +118,8 @@ void machine_power_off(void)
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
/* ipmi_poweroff may have been installed. */
- if (pm_power_off)
- pm_power_off();
-
+ do_power_off();
+
/* It seems we have no way to power the system off via
* software. The user has to press the button himself. */
@@ -132,9 +132,6 @@ void machine_power_off(void)
for (;;);
}
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
void machine_halt(void)
{
machine_power_off();
@@ -32,6 +32,7 @@
#include <linux/of_platform.h>
#include <linux/hugetlb.h>
#include <linux/pgtable.h>
+#include <linux/pm.h>
#include <asm/debugfs.h>
#include <asm/io.h>
#include <asm/paca.h>
@@ -163,9 +164,7 @@ void machine_restart(char *cmd)
void machine_power_off(void)
{
machine_shutdown();
- if (pm_power_off)
- pm_power_off();
-
+ do_power_off();
smp_send_stop();
machine_hang();
}
@@ -26,6 +26,7 @@
#include <linux/ctype.h>
#include <linux/highmem.h>
#include <linux/security.h>
+#include <linux/pm.h>
#include <asm/debugfs.h>
#include <asm/ptrace.h>
@@ -1237,8 +1238,7 @@ static void bootcmds(void)
} else if (cmd == 'h') {
ppc_md.halt();
} else if (cmd == 'p') {
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
}
}
@@ -12,9 +12,6 @@ static void default_power_off(void)
wait_for_interrupt();
}
-void (*pm_power_off)(void) = default_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
void machine_restart(char *cmd)
{
do_kernel_restart(cmd);
@@ -23,10 +20,12 @@ void machine_restart(char *cmd)
void machine_halt(void)
{
- pm_power_off();
+ do_power_off();
+ default_power_off();
}
void machine_power_off(void)
{
- pm_power_off();
+ do_power_off();
+ default_power_off();
}
@@ -302,9 +302,6 @@ void machine_power_off(void)
/*
* Dummy power off function.
*/
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL_GPL(pm_power_off);
-
void *restart_stack;
unsigned long stack_alloc(void)
@@ -10,9 +10,6 @@
#include <asm/tlbflush.h>
#include <asm/traps.h>
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
static void watchdog_trigger_immediate(void)
{
sh_wdt_write_cnt(0xFF);
@@ -46,8 +43,7 @@ static void native_machine_shutdown(void)
static void native_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
}
static void native_machine_halt(void)
@@ -34,12 +34,6 @@
#include <asm/efi.h>
/*
- * Power off function, if any
- */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
-
-/*
* This is set if we need to go through the 'emergency' path.
* When machine_emergency_restart() is called, we may be on
* an inconsistent state and won't be able to do a clean cleanup
@@ -747,11 +741,10 @@ static void native_machine_halt(void)
static void native_machine_power_off(void)
{
- if (pm_power_off) {
- if (!reboot_force)
- machine_shutdown();
- pm_power_off();
- }
+ if (!reboot_force)
+ machine_shutdown();
+ do_power_off();
+
/* A fallback in case there is no PM info available */
tboot_shutdown(TB_SHUTDOWN_HALT);
}
@@ -33,6 +33,7 @@
#include <linux/gfp.h>
#include <linux/edd.h>
#include <linux/objtool.h>
+#include <linux/pm.h>
#include <xen/xen.h>
#include <xen/events.h>
@@ -1084,8 +1085,7 @@ static void xen_machine_halt(void)
static void xen_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_power_off();
xen_reboot(SHUTDOWN_poweroff);
}
@@ -51,10 +51,6 @@
extern void ret_from_fork(void);
extern void ret_from_kernel_thread(void);
-void (*pm_power_off)(void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
-
-
#ifdef CONFIG_STACKPROTECTOR
#include <linux/stackprotector.h>
unsigned long __stack_chk_guard __read_mostly;
@@ -22,6 +22,8 @@
extern void (*pm_power_off)(void);
extern void (*pm_power_off_prepare)(void);
+extern void do_power_off(void);
+
struct device; /* we have a circular dep with device.h */
#ifdef CONFIG_VT_CONSOLE_SLEEP
extern void pm_vt_switch_required(struct device *dev, bool required);
@@ -53,6 +53,16 @@ int reboot_force;
void (*pm_power_off_prepare)(void);
EXPORT_SYMBOL_GPL(pm_power_off_prepare);
+void (*pm_power_off)(void);
+EXPORT_SYMBOL_GPL(pm_power_off);
+
+void do_power_off(void)
+{
+ if (pm_power_off)
+ pm_power_off();
+}
+EXPORT_SYMBOL_GPL(do_power_off);
+
/**
* emergency_restart - reboot the system
*
Move the pm_power_off callback into one global place and also add an function for conditionally calling it (when not NULL), in order to remove code duplication in all individual archs. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> --- arch/alpha/kernel/process.c | 6 ------ arch/arc/kernel/reset.c | 3 --- arch/arm/kernel/reboot.c | 6 ++---- arch/arm64/kernel/process.c | 6 +----- arch/c6x/kernel/process.c | 10 ++-------- arch/csky/kernel/power.c | 10 +++------- arch/h8300/kernel/process.c | 3 --- arch/hexagon/kernel/reset.c | 3 --- arch/ia64/kernel/process.c | 5 +---- arch/m68k/kernel/process.c | 3 --- arch/microblaze/kernel/process.c | 3 --- arch/mips/kernel/reset.c | 6 +----- arch/nds32/kernel/process.c | 7 ++----- arch/nios2/kernel/process.c | 3 --- arch/openrisc/kernel/process.c | 3 --- arch/parisc/kernel/process.c | 9 +++------ arch/powerpc/kernel/setup-common.c | 5 ++--- arch/powerpc/xmon/xmon.c | 4 ++-- arch/riscv/kernel/reset.c | 9 ++++----- arch/s390/kernel/setup.c | 3 --- arch/sh/kernel/reboot.c | 6 +----- arch/x86/kernel/reboot.c | 15 ++++----------- arch/x86/xen/enlighten_pv.c | 4 ++-- arch/xtensa/kernel/process.c | 4 ---- include/linux/pm.h | 2 ++ kernel/reboot.c | 10 ++++++++++ 26 files changed, 42 insertions(+), 106 deletions(-)