kernel: Add support for poweroff handler call chain
Subsystems (58)
PATCH v2 40/47 mips: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
If there is an indication that there can be more than one poweroff handler, use register_power_off_handler, otherwise use register_power_off_handler_simple to register the poweroff handler.
If the poweroff handler only resets or stops the system, select the fallback priority to indicate that the poweroff handler is one of last resort. If the poweroff handler powers off the system, select the default priority, unless the poweroff handler installation code suggests that there can be more than one poweroff handler and the new handler is only installed conditionally. In this case, install the handler with low priority.
---
- Use defines to specify poweroff handler priorities
arch/mips/alchemy/board-gpr.c | 3 ++- arch/mips/alchemy/board-mtx1.c | 3 ++- arch/mips/alchemy/board-xxs1500.c | 3 ++- arch/mips/alchemy/devboards/platform.c | 17 +++++++++++++++-- arch/mips/ar7/setup.c | 3 ++- arch/mips/ath79/setup.c | 3 ++- arch/mips/bcm47xx/setup.c | 3 ++- arch/mips/bcm63xx/setup.c | 3 ++- arch/mips/cobalt/setup.c | 3 ++- arch/mips/dec/setup.c | 3 ++- arch/mips/emma/markeins/setup.c | 3 ++- arch/mips/jz4740/reset.c | 3 ++- arch/mips/lantiq/falcon/reset.c | 3 ++- arch/mips/lantiq/xway/reset.c | 3 ++- arch/mips/lasat/reset.c | 3 ++- arch/mips/loongson/common/reset.c | 3 ++- arch/mips/loongson1/common/reset.c | 3 ++- arch/mips/mti-malta/malta-reset.c | 3 ++- arch/mips/mti-sead3/sead3-reset.c | 3 ++- arch/mips/netlogic/xlp/setup.c | 3 ++- arch/mips/netlogic/xlr/setup.c | 3 ++- arch/mips/pmcs-msp71xx/msp_setup.c | 3 ++- arch/mips/pnx833x/common/setup.c | 3 ++- arch/mips/ralink/reset.c | 3 ++- arch/mips/rb532/setup.c | 3 ++- arch/mips/sgi-ip22/ip22-reset.c | 3 ++- arch/mips/sgi-ip27/ip27-reset.c | 3 ++- arch/mips/sgi-ip32/ip32-reset.c | 3 ++- arch/mips/sibyte/common/cfe.c | 3 ++- arch/mips/sni/setup.c | 3 ++- arch/mips/txx9/generic/setup.c | 3 ++- arch/mips/vr41xx/common/pmu.c | 3 ++- 32 files changed, 77 insertions(+), 33 deletions(-)
arch/mips/alchemy/board-gpr.c +2 -1
@@ -89,7 +89,8 @@ void __init board_setup(void) {printk (KERN_INFO "Trapeze ITS GPR board\n" ); - pm_power_off = gpr_power_off; +register_power_off_handler_simple (gpr_power_off, +POWEROFF_PRIORITY_FALLBACK ); _machine_halt = gpr_power_off; _machine_restart = gpr_reset;
arch/mips/alchemy/board-mtx1.c +2 -1
@@ -98,7 +98,8 @@ void __init board_setup(void)alchemy_gpio_direction_output (211 ,1 );/* green on */ alchemy_gpio_direction_output (212 ,0 );/* red off */ - pm_power_off = mtx1_power_off; +register_power_off_handler_simple (mtx1_power_off, +POWEROFF_PRIORITY_FALLBACK ); _machine_halt = mtx1_power_off; _machine_restart = mtx1_reset;
arch/mips/alchemy/board-xxs1500.c +2 -1
@@ -79,7 +79,8 @@ void __init board_setup(void) {u32 pin_func; - pm_power_off = xxs1500_power_off; +register_power_off_handler_simple (xxs1500_power_off, +POWEROFF_PRIORITY_FALLBACK ); _machine_halt = xxs1500_power_off; _machine_restart = xxs1500_reset;
arch/mips/alchemy/devboards/platform.c +15 -2
@@ -6,6 +6,7 @@#include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/physmap.h> +#include <linux/notifier.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/pm.h>
@@ -64,10 +65,22 @@ static void db1x_reset(char *c)bcsr_write (BCSR_SYSTEM ,0 ); } +static int db1x_power_off_notify (struct notifier_block *this, +unsigned long unused1,void *unused2) +{ +db1x_power_off (); +return NOTIFY_DONE ; +} + +static struct notifier_block db1x_poweroff_nb = { + .notifier_call = db1x_power_off_notify, + .priority =POWEROFF_PRIORITY_LOW , +}; +static int __init db1x_late_setup (void ) { -if (!pm_power_off) - pm_power_off = db1x_power_off; +if (register_power_off_handler (&db1x_poweroff_nb)) +pr_warn ("dbx1: Failed to register poweroff handler\n" );if (!_machine_halt) _machine_halt = db1x_power_off;if (!_machine_restart)
arch/mips/ar7/setup.c +2 -1
@@ -91,7 +91,8 @@ void __init plat_mem_setup(void) _machine_restart = ar7_machine_restart; _machine_halt = ar7_machine_halt; - pm_power_off = ar7_machine_power_off; +register_power_off_handler_simple (ar7_machine_power_off, +POWEROFF_PRIORITY_DEFAULT ); io_base = (unsigned long )ioremap (AR7_REGS_BASE ,0x10000 );if (!io_base)
arch/mips/ath79/setup.c +2 -1
@@ -203,7 +203,8 @@ void __init plat_mem_setup(void) _machine_restart = ath79_restart; _machine_halt = ath79_halt; - pm_power_off = ath79_halt; +register_power_off_handler_simple (ath79_halt, +POWEROFF_PRIORITY_FALLBACK ); }void __init plat_time_init (void )
arch/mips/bcm47xx/setup.c +2 -1
@@ -246,7 +246,8 @@ void __init plat_mem_setup(void) _machine_restart = bcm47xx_machine_restart; _machine_halt = bcm47xx_machine_halt; - pm_power_off = bcm47xx_machine_halt; +register_power_off_handler_simple (bcm47xx_machine_halt, +POWEROFF_PRIORITY_FALLBACK );bcm47xx_board_detect ();mips_set_machine_name (bcm47xx_board_get_name ()); }
arch/mips/bcm63xx/setup.c +2 -1
@@ -149,7 +149,8 @@ void __init plat_mem_setup(void) _machine_halt = bcm63xx_machine_halt; _machine_restart = __bcm63xx_machine_reboot; - pm_power_off = bcm63xx_machine_halt; +register_power_off_handler_simple (bcm63xx_machine_halt, +POWEROFF_PRIORITY_FALLBACK );set_io_port_base (0 ); ioport_resource.start =0 ;
arch/mips/cobalt/setup.c +2 -1
@@ -78,7 +78,8 @@ void __init plat_mem_setup(void) _machine_restart = cobalt_machine_restart; _machine_halt = cobalt_machine_halt; - pm_power_off = cobalt_machine_halt; +register_power_off_handler_simple (cobalt_machine_halt, +POWEROFF_PRIORITY_FALLBACK );set_io_port_base (CKSEG1ADDR (GT_DEF_PCI0_IO_BASE ));
arch/mips/dec/setup.c +2 -1
@@ -158,7 +158,8 @@ void __init plat_mem_setup(void) _machine_restart = dec_machine_restart; _machine_halt = dec_machine_halt; - pm_power_off = dec_machine_power_off; +register_power_off_handler_simple (dec_machine_power_off, +POWEROFF_PRIORITY_DEFAULT ); ioport_resource.start = ~0UL ; ioport_resource.end =0UL ;
arch/mips/emma/markeins/setup.c +2 -1
@@ -103,7 +103,8 @@ void __init plat_mem_setup(void) _machine_restart = markeins_machine_restart; _machine_halt = markeins_machine_halt; - pm_power_off = markeins_machine_power_off; +register_power_off_handler_simple (markeins_machine_power_off, +POWEROFF_PRIORITY_FALLBACK );/* setup resource limits */ ioport_resource.start =EMMA2RH_PCI_IO_BASE ;
arch/mips/jz4740/reset.c +2 -1
@@ -114,5 +114,6 @@ void jz4740_reset_init(void) { _machine_restart = jz4740_restart; _machine_halt = jz4740_halt; - pm_power_off = jz4740_power_off; +register_power_off_handler_simple (jz4740_power_off, +POWEROFF_PRIORITY_DEFAULT ); }
arch/mips/lantiq/falcon/reset.c +2 -1
@@ -83,7 +83,8 @@ static int __init mips_reboot_setup(void) { _machine_restart = machine_restart; _machine_halt = machine_halt; - pm_power_off = machine_power_off; +register_power_off_handler_simple (machine_power_off, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
arch/mips/lantiq/xway/reset.c +2 -1
@@ -157,7 +157,8 @@ static int __init mips_reboot_setup(void) _machine_restart = ltq_machine_restart; _machine_halt = ltq_machine_halt; - pm_power_off = ltq_machine_power_off; +register_power_off_handler_simple (ltq_machine_power_off, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
arch/mips/lasat/reset.c +2 -1
@@ -56,5 +56,6 @@ void lasat_reboot_setup(void) { _machine_restart = lasat_machine_restart; _machine_halt = lasat_machine_halt; - pm_power_off = lasat_machine_halt; +register_power_off_handler_simple (lasat_machine_halt, +POWEROFF_PRIORITY_FALLBACK ); }
arch/mips/loongson/common/reset.c +2 -1
@@ -84,7 +84,8 @@ static int __init mips_reboot_setup(void) { _machine_restart = loongson_restart; _machine_halt = loongson_halt; - pm_power_off = loongson_poweroff; +register_power_off_handler_simple (loongson_poweroff, +POWEROFF_PRIORITY_DEFAULT );return 0 ; }
arch/mips/loongson1/common/reset.c +2 -1
@@ -38,7 +38,8 @@ static int __init ls1x_reboot_setup(void) { _machine_restart = ls1x_restart; _machine_halt = ls1x_halt; - pm_power_off = ls1x_power_off; +register_power_off_handler_simple (ls1x_power_off, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
arch/mips/mti-malta/malta-reset.c +2 -1
@@ -40,7 +40,8 @@ static int __init mips_reboot_setup(void) { _machine_restart = mips_machine_restart; _machine_halt = mips_machine_halt; - pm_power_off = mips_machine_power_off; +register_power_off_handler_simple (mips_machine_power_off, +POWEROFF_PRIORITY_DEFAULT );return 0 ; }
arch/mips/mti-sead3/sead3-reset.c +2 -1
@@ -33,7 +33,8 @@ static int __init mips_reboot_setup(void) { _machine_restart = mips_machine_restart; _machine_halt = mips_machine_halt; - pm_power_off = mips_machine_halt; +register_power_off_handler_simple (mips_machine_halt, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
arch/mips/netlogic/xlp/setup.c +2 -1
@@ -106,7 +106,8 @@ void __init plat_mem_setup(void)#endif _machine_restart = (void (*)(char *))nlm_linux_exit; _machine_halt = nlm_linux_exit; - pm_power_off = nlm_linux_exit; +register_power_off_handler_simple (nlm_linux_exit, +POWEROFF_PRIORITY_FALLBACK );/* memory and bootargs from DT */ xlp_early_init_devtree ();
arch/mips/netlogic/xlr/setup.c +2 -1
@@ -75,7 +75,8 @@ void __init plat_mem_setup(void) { _machine_restart = (void (*)(char *))nlm_linux_exit; _machine_halt = nlm_linux_exit; - pm_power_off = nlm_linux_exit; +register_power_off_handler_simple (nlm_linux_exit, +POWEROFF_PRIORITY_FALLBACK ); }const char *get_system_type (void )
arch/mips/pmcs-msp71xx/msp_setup.c +2 -1
@@ -144,7 +144,8 @@ void __init plat_mem_setup(void) { _machine_restart = msp_restart; _machine_halt = msp_halt; - pm_power_off = msp_power_off; +register_power_off_handler_simple (msp_power_off, +POWEROFF_PRIORITY_FALLBACK ); }void __init prom_init (void )
arch/mips/pnx833x/common/setup.c +2 -1
@@ -51,7 +51,8 @@ int __init plat_mem_setup(void) _machine_restart = pnx833x_machine_restart; _machine_halt = pnx833x_machine_halt; - pm_power_off = pnx833x_machine_power_off; +register_power_off_handler_simple (pnx833x_machine_power_off, +POWEROFF_PRIORITY_DEFAULT );/* IO/MEM resources. */ set_io_port_base (KSEG1 );
arch/mips/ralink/reset.c +2 -1
@@ -98,7 +98,8 @@ static int __init mips_reboot_setup(void) { _machine_restart = ralink_restart; _machine_halt = ralink_halt; - pm_power_off = ralink_halt; +register_power_off_handler_simple (ralink_halt, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
arch/mips/rb532/setup.c +2 -1
@@ -44,7 +44,8 @@ void __init plat_mem_setup(void) _machine_restart = rb_machine_restart; _machine_halt = rb_machine_halt; - pm_power_off = rb_machine_halt; +register_power_off_handler_simple (rb_machine_halt, +POWEROFF_PRIORITY_FALLBACK );set_io_port_base (KSEG1 );
arch/mips/sgi-ip22/ip22-reset.c +2 -1
@@ -188,7 +188,8 @@ static int __init reboot_setup(void) _machine_restart = sgi_machine_restart; _machine_halt = sgi_machine_halt; - pm_power_off = sgi_machine_power_off; +register_power_off_handler_simple (sgi_machine_power_off, +POWEROFF_PRIORITY_DEFAULT ); res =request_irq (SGI_PANEL_IRQ , panel_int,0 ,"Front Panel" ,NULL );if (res) {
arch/mips/sgi-ip27/ip27-reset.c +2 -1
@@ -76,5 +76,6 @@ void ip27_reboot_setup(void) { _machine_restart = ip27_machine_restart; _machine_halt = ip27_machine_halt; - pm_power_off = ip27_machine_power_off; +register_power_off_handler_simple (ip27_machine_power_off, +POWEROFF_PRIORITY_FALLBACK ); }
arch/mips/sgi-ip32/ip32-reset.c +2 -1
@@ -189,7 +189,8 @@ static __init int ip32_reboot_setup(void) _machine_restart = ip32_machine_restart; _machine_halt = ip32_machine_halt; - pm_power_off = ip32_machine_power_off; +register_power_off_handler_simple (ip32_machine_power_off, +POWEROFF_PRIORITY_FALLBACK );init_timer (&blink_timer); blink_timer.function = blink_timeout;
arch/mips/sibyte/common/cfe.c +2 -1
@@ -245,7 +245,8 @@ void __init prom_init(void) _machine_restart = cfe_linux_restart; _machine_halt = cfe_linux_halt; - pm_power_off = cfe_linux_halt; +register_power_off_handler_simple (cfe_linux_halt, +POWEROFF_PRIORITY_FALLBACK );/* * Check if a loader was used; if NOT, the 4 arguments are
arch/mips/sni/setup.c +2 -1
@@ -225,7 +225,8 @@ void __init plat_mem_setup(void) } _machine_restart = sni_machine_restart; - pm_power_off = sni_machine_power_off; +register_power_off_handler_simple (sni_machine_power_off, +POWEROFF_PRIORITY_DEFAULT );sni_display_setup ();sni_console_setup ();
arch/mips/txx9/generic/setup.c +2 -1
@@ -555,7 +555,8 @@ void __init plat_mem_setup(void)/* fallback restart/halt routines */ _machine_restart = (void (*)(char *))txx9_machine_halt; _machine_halt = txx9_machine_halt; - pm_power_off = txx9_machine_halt; +register_power_off_handler_simple (txx9_machine_halt, +POWEROFF_PRIORITY_FALLBACK );#ifdef CONFIG_PCI pcibios_plat_setup = txx9_pcibios_setup;
arch/mips/vr41xx/common/pmu.c +2 -1
@@ -127,7 +127,8 @@ static int __init vr41xx_pmu_init(void) cpu_wait = vr41xx_cpu_wait; _machine_restart = vr41xx_restart; _machine_halt = vr41xx_halt; - pm_power_off = vr41xx_halt; +register_power_off_handler_simple (vr41xx_halt, +POWEROFF_PRIORITY_FALLBACK );return 0 ; }
Signature · 1 line
1.9.1
Re: [PATCH v2 40/47] mips: Register with kernel poweroff handler
Re: [PATCH v2 40/47] mips: Register with kernel poweroff handler
PATCH v2 41/47 sh: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
---
- Use defines to specify poweroff handler priorities
arch/sh/boards/board-sh7785lcr.c | 3 ++- arch/sh/boards/board-urquell.c | 3 ++- arch/sh/boards/mach-highlander/setup.c | 3 ++- arch/sh/boards/mach-landisk/setup.c | 3 ++- arch/sh/boards/mach-r2d/setup.c | 3 ++- arch/sh/boards/mach-sdk7786/setup.c | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-)
arch/sh/boards/board-sh7785lcr.c +2 -1
@@ -332,7 +332,8 @@ static void __init sh7785lcr_setup(char **cmdline_p)printk (KERN_INFO "Renesas Technology Corp. R0P7785LC0011RL support.\n" ); - pm_power_off = sh7785lcr_power_off; +register_power_off_handler_simple (sh7785lcr_power_off, +POWEROFF_PRIORITY_DEFAULT );/* sm501 DRAM configuration */ sm501_reg =ioremap_nocache (SM107_REG_ADDR ,SM501_DRAM_CONTROL );
arch/sh/boards/board-urquell.c +2 -1
@@ -204,7 +204,8 @@ static void __init urquell_setup(char **cmdline_p) {printk (KERN_INFO "Renesas Technology Corp. Urquell support.\n" ); - pm_power_off = urquell_power_off; +register_power_off_handler_simple (urquell_power_off, +POWEROFF_PRIORITY_DEFAULT );register_smp_ops (&shx3_smp_ops); }
arch/sh/boards/mach-highlander/setup.c +2 -1
@@ -385,7 +385,8 @@ static void __init highlander_setup(char **cmdline_p)__raw_writew (__raw_readw (PA_IVDRCTL ) |0x01 ,PA_IVDRCTL );/* Si13112 */ - pm_power_off = r7780rp_power_off; +register_power_off_handler_simple (r7780rp_power_off, +POWEROFF_PRIORITY_DEFAULT ); }static unsigned char irl2irq[HL_NR_IRL ];
arch/sh/boards/mach-landisk/setup.c +2 -1
@@ -89,7 +89,8 @@ static void __init landisk_setup(char **cmdline_p)__raw_writeb (__raw_readb (PA_LED ) |0x03 ,PA_LED );printk (KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n" ); - pm_power_off = landisk_power_off; +register_power_off_handler_simple (landisk_power_off, +POWEROFF_PRIORITY_DEFAULT ); }/*
arch/sh/boards/mach-r2d/setup.c +2 -1
@@ -279,7 +279,8 @@ static void __init rts7751r2d_setup(char **cmdline_p) (ver >> 4) & 0xf, ver & 0xf);__raw_writew (0x0000 ,PA_OUTPORT ); - pm_power_off = rts7751r2d_power_off; +register_power_off_handler_simple (rts7751r2d_power_off, +POWEROFF_PRIORITY_DEFAULT );/* sm501 dram configuration: * ColSizeX = 11 - External Memory Column Size: 256 words.
arch/sh/boards/mach-sdk7786/setup.c +2 -1
@@ -252,7 +252,8 @@ static void __init sdk7786_setup(char **cmdline_p)pr_info ("\tPCB revision:\t%d\n" ,fpga_read_reg (PCBRR ) &0xf ); machine_ops.restart = sdk7786_restart; - pm_power_off = sdk7786_power_off; +register_power_off_handler_simple (sdk7786_power_off, +POWEROFF_PRIORITY_DEFAULT );register_smp_ops (&shx3_smp_ops); }
Signature · 1 line
1.9.1
PATCH v2 42/47 x86: lguest: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
---
- Use define to specify poweroff handler priority
arch/x86/lguest/boot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/lguest/boot.c +2 -1
@@ -1441,7 +1441,8 @@ __init void lguest_init(void)* the Guest routine to power off, and the reboot hook to our restart * routine. */ - pm_power_off = lguest_power_off; +register_power_off_handler_simple (lguest_power_off, +POWEROFF_PRIORITY_DEFAULT ); machine_ops.restart = lguest_restart;/*
Signature · 1 line
1.9.1
PATCH v2 43/47 x86: ce4100: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
---
- Use define to specify poweroff handler priority
arch/x86/platform/ce4100/ce4100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/platform/ce4100/ce4100.c +2 -1
@@ -164,5 +164,6 @@ void __init x86_ce4100_early_setup(void)*/ reboot_type =BOOT_KBD ; - pm_power_off = ce4100_power_off; +register_power_off_handler_simple (ce4100_power_off, +POWEROFF_PRIORITY_DEFAULT ); }
Signature · 1 line
1.9.1
PATCH v2 44/47 x86: intel-mid: Drop registration of dummy poweroff handlers
In reply to Guenter RoeckA dummy poweroff handler does not serve any purpose. Drop it.
---
- Use define to specify poweroff handler priority
arch/x86/platform/intel-mid/intel-mid.c | 5 ----- arch/x86/platform/intel-mid/mfld.c | 5 ----- 2 files changed, 10 deletions(-)
arch/x86/platform/intel-mid/intel-mid.c +0 -5
@@ -67,10 +67,6 @@ static void *(*get_intel_mid_ops[])(void) = INTEL_MID_OPS_INIT;enum intel_mid_cpu_type __intel_mid_cpu_chip;EXPORT_SYMBOL_GPL (__intel_mid_cpu_chip); -static void intel_mid_power_off (void ) -{ -}; -static void intel_mid_reboot (void ) {intel_scu_ipc_simple_command (IPCMSG_COLD_BOOT ,0 );
@@ -183,7 +179,6 @@ void __init x86_intel_mid_early_setup(void) legacy_pic = &null_legacy_pic; - pm_power_off = intel_mid_power_off; machine_ops.emergency_restart = intel_mid_reboot;/* Avoid searching for BIOS MP tables */
arch/x86/platform/intel-mid/mfld.c +0 -5
@@ -23,10 +23,6 @@ static struct intel_mid_ops penwell_ops = { .arch_setup = penwell_arch_setup, }; -static void mfld_power_off (void ) -{ -} -static unsigned long __init mfld_calibrate_tsc (void ) {unsigned long fast_calibrate;
@@ -61,7 +57,6 @@ static unsigned long __init mfld_calibrate_tsc(void)static void __init penwell_arch_setup (void ) { x86_platform.calibrate_tsc = mfld_calibrate_tsc; - pm_power_off = mfld_power_off; }void *get_penwell_ops (void )
Signature · 1 line
1.9.1
PATCH v2 45/47 x86: pmc_atom: Register poweroff handler with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly. Register with low priority to reflect that the original code only sets pm_power_off if it was not already set.
---
- Use define to specify poweroff handler priority
- Use dev_warn instead of dev_err
arch/x86/kernel/pmc_atom.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
arch/x86/kernel/pmc_atom.c +17 -3
@@ -20,6 +20,8 @@#include <linux/pci.h> #include <linux/device.h> #include <linux/debugfs.h> +#include <linux/notifier.h> +#include <linux/pm.h> #include <linux/seq_file.h> #include <linux/io.h>
@@ -92,7 +94,8 @@ static inline void pmc_reg_write(struct pmc_dev *pmc, int reg_offset, u32 val)writel (val, pmc->regmap + reg_offset); } -static void pmc_power_off (void ) +static int pmc_power_off (struct notifier_block *this,unsigned long unused1, +void *unused2) {u16 pm1_cnt_port;u32 pm1_cnt_value;
@@ -107,8 +110,15 @@ static void pmc_power_off(void) pm1_cnt_value |=SLEEP_ENABLE ;outl (pm1_cnt_value, pm1_cnt_port); + +return NOTIFY_DONE ; } +static struct notifier_block pmc_poweroff_nb = { + .notifier_call = pmc_power_off, + .priority =POWEROFF_PRIORITY_LOW , +}; +static void pmc_hw_reg_setup (struct pmc_dev *pmc) {/*
@@ -252,8 +262,12 @@ static int pmc_setup_dev(struct pci_dev *pdev) acpi_base_addr &=ACPI_BASE_ADDR_MASK ;/* Install power off function */ -if (acpi_base_addr !=0 && pm_power_off ==NULL ) - pm_power_off = pmc_power_off; +if (acpi_base_addr !=0 ) { + ret =register_power_off_handler (&pmc_poweroff_nb); +if (ret) +dev_warn (&pdev->dev, +"Failed to install poweroff handler\n" ); + }pci_read_config_dword (pdev,PMC_BASE_ADDR_OFFSET , &pmc->base_addr); pmc->base_addr &=PMC_BASE_ADDR_MASK ;
Signature · 1 line
1.9.1
PATCH v2 46/47 efi: Register poweroff handler with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly. Register with low priority since the efi code states that this is a poweroff handler of last resort.
---
- Use define to specify poweroff handler priority
drivers/firmware/efi/reboot.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/firmware/efi/reboot.c +19 -4
@@ -3,6 +3,8 @@* Copyright (c) 2014 Red Hat, Inc., Mark Salter <[email protected]> */ #include <linux/efi.h> +#include <linux/notifier.h> +#include <linux/pm.h> #include <linux/reboot.h> int efi_reboot_quirk_mode =-1 ;
@@ -38,19 +40,32 @@ bool __weak efi_poweroff_required(void)return false; } -static void efi_power_off (void ) +static int efi_power_off (struct notifier_block *this, +unsigned long unused1,void *unused2) { efi.reset_system (EFI_RESET_SHUTDOWN ,EFI_SUCCESS ,0 ,NULL ); + +return NOTIFY_DONE ; } +static struct notifier_block efi_poweroff_nb = { + .notifier_call = efi_power_off, + .priority =POWEROFF_PRIORITY_LOW , +}; +static int __init efi_shutdown_init (void ) { +int ret =0 ; +if (!efi_enabled (EFI_RUNTIME_SERVICES ))return -ENODEV ; -if (efi_poweroff_required ()) - pm_power_off = efi_power_off; +if (efi_poweroff_required ()) { + ret =register_power_off_handler (&efi_poweroff_nb); +if (ret) +pr_err ("efi: Failed to register poweroff handler\n" ); + } -return 0 ; +return ret; }late_initcall (efi_shutdown_init);
Signature · 1 line
1.9.1
PATCH v2 47/47 kernel: Remove pm_power_off
In reply to Guenter RoeckNo users of pm_power_off are left, so it is safe to remove the function.
---
v2: poweroff -> power_off
include/linux/pm.h | 1 - kernel/power/poweroff_handler.c | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-)
include/linux/pm.h +0 -1
@@ -31,7 +31,6 @@/* * Callbacks for platform drivers to implement. */ -extern void (*pm_power_off)(void );extern void (*pm_power_off_prepare)(void );/*
kernel/power/poweroff_handler.c +1 -9
@@ -22,12 +22,6 @@#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); - -/* * Notifier list for kernel code which wants to be called * to power off the system. */
@@ -242,8 +236,6 @@ EXPORT_SYMBOL(devm_register_power_off_handler);void do_kernel_power_off (void ) {spin_lock (&power_off_handler_lock); -if (pm_power_off) -pm_power_off ();raw_notifier_call_chain (&power_off_handler_list,0 ,NULL );spin_unlock (&power_off_handler_lock); }
@@ -255,6 +247,6 @@ void do_kernel_power_off(void)*/ bool have_kernel_power_off (void ) { -return pm_power_off !=NULL || power_off_handler_list.head !=NULL ; +return power_off_handler_list.head !=NULL ; }EXPORT_SYMBOL (have_kernel_power_off);
Signature · 1 line
1.9.1