kernel: Add support for poweroff handler call chain
Subsystems (11)
Guenter Roeck
maintainercover kernel: Add support for poweroff handler call chain
Various drivers implement architecture and/or device specific means to remove power from the system. For the most part, those drivers set the global variable pm_power_off to point to a function within the driver.
This mechanism has a number of drawbacks. Typically only one scheme to remove power is supported (at least if pm_power_off is used). At least in theory there can be multiple means remove power, some of which may be less desirable. For example, some mechanisms may only power off the CPU or the CPU card, while another may power off the entire system. Others may really just execute a restart sequence or drop into the ROM monitor. Using pm_power_off can also be racy if the function pointer is set from a driver built as module, as the driver may be in the process of being unloaded when pm_power_off is called. If there are multiple poweroff handlers in the system, removing a module with such a handler may inadvertently reset the pointer to pm_power_off to NULL, leaving the system with no means to remove power.
Introduce a system poweroff handler call chain to solve the described problems. This call chain is expected to be executed from the architecture specific machine_power_off() function. Drivers providing system poweroff functionality are expected to register with this call chain. By using the priority field in the notifier block, callers can control poweroff handler execution sequence and thus ensure that the poweroff handler with the optimal capabilities to remove power for a given system is called first.
The poweroff handler is introduced in multiple steps
1) Implement poweroff handler API.
Patch 01/16.
2) Ensure that pm_power_off is only called from machine_restart. Patches 02/16 and 03/16.
3) Implement call to poweroff handler in architecture specific machine_restart code.
Patches 03/16 to 13/16.
4) Convert all drivers to register with poweroff handler instead of setting pm_power_off directly.
Patches 15/16 and 16/16 (examples).
This can be done in two steps: First convert all drivers which can be built as modules, then convert the remaining drivers (possibly after unexporting pm_powr_off).
5) Unexport pm_power_off for all architectures,
and drop it entirely for architectures where it is not really used.
6) [optional] Convert machine specific architecture code to register with poweroff handler instead of setting pm_power_off directly, and remove pm_power_off entirely from the system.
----------------------------------------------------------------
Guenter Roeck (16):
kernel: Add support for poweroff handler call chain
hwmon: (ab8500) Call kernel_power_off instead of pm_power_off
parisc: support poweroff through poweroff handler call chain
arm: support poweroff through poweroff handler call chain
arm64: support poweroff through poweroff handler call chain
avr32: support poweroff through poweroff handler call chain
c6x: support poweroff through poweroff handler call chain
ia64: support poweroff through poweroff handler call chain
metag: support poweroff through poweroff handler call chain
mips: support poweroff through poweroff handler call chain
sh: support poweroff through poweroff handler call chain
unicore32: support poweroff through poweroff handler call chain
x86: support poweroff through poweroff handler call chain x86/xen: support poweroff through poweroff handler call chain power/reset: restart-poweroff: Register with kernel poweroff handler
mfd: palmas: Register with kernel poweroff handler
arch/arm/kernel/process.c | 2 + arch/arm64/kernel/process.c | 2 + arch/avr32/kernel/process.c | 2 + arch/c6x/kernel/process.c | 2 + arch/ia64/kernel/process.c | 2 + arch/metag/kernel/process.c | 2 + arch/mips/kernel/reset.c | 2 + arch/parisc/kernel/process.c | 7 ++- arch/sh/kernel/reboot.c | 2 + arch/unicore32/kernel/process.c | 2 + arch/x86/kernel/reboot.c | 4 ++ arch/x86/xen/enlighten.c | 2 + drivers/hwmon/ab8500.c | 5 ++- drivers/mfd/palmas.c | 30 +++++++------ drivers/parisc/power.c | 3 +- drivers/power/reset/restart-poweroff.c | 24 +++++----- include/linux/mfd/palmas.h | 3 ++ include/linux/reboot.h | 4 ++ kernel/reboot.c | 81 ++++++++++++++++++++++++++++++++++ 19 files changed, 149 insertions(+), 32 deletions(-)
Guenter Roeck
maintainerRFC PATCH 1/16 kernel: Add support for poweroff handler call chain
Various drivers implement architecture and/or device specific means to remove power from the system. For the most part, those drivers set the global variable pm_power_off to point to a function within the driver.
This mechanism has a number of drawbacks. Typically only one scheme to remove power is supported (at least if pm_power_off is used). At least in theory there can be multiple means remove power, some of which may be less desirable. For example, some mechanisms may only power off the CPU or the CPU card, while another may power off the entire system. Others may really just execute a restart sequence or drop into the ROM monitor. Using pm_power_off can also be racy if the function pointer is set from a driver built as module, as the driver may be in the process of being unloaded when pm_power_off is called. If there are multiple poweroff handlers in the system, removing a module with such a handler may inadvertently reset the pointer to pm_power_off to NULL, leaving the system with no means to remove power.
Introduce a system poweroff handler call chain to solve the described problems. This call chain is expected to be executed from the architecture specific machine_power_off() function. Drivers providing system poweroff functionality are expected to register with this call chain. By using the priority field in the notifier block, callers can control poweroff handler execution sequence and thus ensure that the poweroff handler with the optimal capabilities to remove power for a given system is called first.
--- include/linux/reboot.h | 4 +++ kernel/reboot.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
include/linux/reboot.h +4 -0
@@ -38,6 +38,10 @@ extern int reboot_force;extern int register_reboot_notifier (struct notifier_block *);extern int unregister_reboot_notifier (struct notifier_block *); +extern int register_poweroff_handler (struct notifier_block *); +extern int unregister_poweroff_handler (struct notifier_block *); +extern void do_kernel_poweroff (void ); +extern int register_restart_handler (struct notifier_block *);extern int unregister_restart_handler (struct notifier_block *);extern void do_kernel_restart (char *cmd);
kernel/reboot.c +81 -0
87 lines not on this page · raw message
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 1/16 kernel: Add support for poweroff handler call chain
In reply to Guenter RoeckVarious drivers implement architecture and/or device specific means to remove power from the system. For the most part, those drivers set the global variable pm_power_off to point to a function within the driver.
This mechanism has a number of drawbacks. Typically only one scheme to remove power is supported (at least if pm_power_off is used). At least in theory there can be multiple means remove power, some of which may be less desirable. For example, some mechanisms may only power off the CPU or the CPU card, while another may power off the entire system. Others may really just execute a restart sequence or drop into the ROM monitor. Using pm_power_off can also be racy if the function pointer is set from a driver built as module, as the driver may be in the process of being unloaded when pm_power_off is called. If there are multiple poweroff handlers in the system, removing a module with such a handler may inadvertently reset the pointer to pm_power_off to NULL, leaving the system with no means to remove power.
Introduce a system poweroff handler call chain to solve the described problems. This call chain is expected to be executed from the architecture specific machine_power_off() function. Drivers providing system poweroff functionality are expected to register with this call chain. By using the priority field in the notifier block, callers can control poweroff handler execution sequence and thus ensure that the poweroff handler with the optimal capabilities to remove power for a given system is called first.
--- include/linux/reboot.h | 4 +++ kernel/reboot.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
include/linux/reboot.h +4 -0
@@ -38,6 +38,10 @@ extern int reboot_force;extern int register_reboot_notifier (struct notifier_block *);extern int unregister_reboot_notifier (struct notifier_block *); +extern int register_poweroff_handler (struct notifier_block *); +extern int unregister_poweroff_handler (struct notifier_block *); +extern void do_kernel_poweroff (void ); +extern int register_restart_handler (struct notifier_block *);extern int unregister_restart_handler (struct notifier_block *);extern void do_kernel_restart (char *cmd);
kernel/reboot.c +81 -0
87 lines not on this page · raw message
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 2/16 hwmon: (ab8500) Call kernel_power_off instead of pm_power_off
In reply to Guenter RoeckDrivers should not call pm_power_off directly; it is not guaranteed to be non-NULL. Call kernel_power_off instead.
---
I already submitted this patch separately as non-RFC. It is included in this series for completeness.
drivers/hwmon/ab8500.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hwmon/ab8500.c +3 -2
@@ -6,7 +6,7 @@* * When the AB8500 thermal warning temperature is reached (threshold cannot * be changed by SW), an interrupt is set, and if no further action is taken -* within a certain time frame, pm_power off will be called. +* within a certain time frame, kernel_power_off will be called. * * When AB8500 thermal shutdown temperature is reached a hardware shutdown of * the AB8500 will occur.
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/power/ab8500.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <linux/sysfs.h> #include "abx500.h"
@@ -106,7 +107,7 @@ static void ab8500_thermal_power_off(struct work_struct *work)dev_warn (&abx500_data->pdev->dev,"Power off due to critical temp\n" ); -pm_power_off (); +kernel_power_off (); } static ssize_t ab8500_show_name(struct device *dev,
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 2/16 hwmon: (ab8500) Call kernel_power_off instead of pm_power_off
In reply to Guenter RoeckDrivers should not call pm_power_off directly; it is not guaranteed to be non-NULL. Call kernel_power_off instead.
---
I already submitted this patch separately as non-RFC. It is included in this series for completeness.
drivers/hwmon/ab8500.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hwmon/ab8500.c +3 -2
@@ -6,7 +6,7 @@* * When the AB8500 thermal warning temperature is reached (threshold cannot * be changed by SW), an interrupt is set, and if no further action is taken -* within a certain time frame, pm_power off will be called. +* within a certain time frame, kernel_power_off will be called. * * When AB8500 thermal shutdown temperature is reached a hardware shutdown of * the AB8500 will occur.
@@ -21,6 +21,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/power/ab8500.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <linux/sysfs.h> #include "abx500.h"
@@ -106,7 +107,7 @@ static void ab8500_thermal_power_off(struct work_struct *work)dev_warn (&abx500_data->pdev->dev,"Power off due to critical temp\n" ); -pm_power_off (); +kernel_power_off (); } static ssize_t ab8500_show_name(struct device *dev,
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 3/16 parisc: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it from machine_power_off.
Also, do not use pm_power_off as alternate pointer to machine_power_off. Have the parisc/power driver call kernel_power_off() which in turn will call machine_power_off().
--- arch/parisc/kernel/process.c | 7 +++++-- drivers/parisc/power.c | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/parisc/kernel/process.c +5 -2
@@ -42,6 +42,7 @@#include <linux/module.h> #include <linux/personality.h> #include <linux/ptrace.h> +#include <linux/reboot.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/stddef.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_poweroff (); +/* It seems we have no way to power the system off via * software. The user has to press the button himself. */
@@ -141,7 +144,7 @@ void machine_power_off(void) "Please power this system off now."); } -void (*pm_power_off)(void ) = machine_power_off; +void (*pm_power_off)(void );EXPORT_SYMBOL (pm_power_off);/*
drivers/parisc/power.c +1 -2
@@ -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 (); } } }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 3/16 parisc: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it from machine_power_off.
Also, do not use pm_power_off as alternate pointer to machine_power_off. Have the parisc/power driver call kernel_power_off() which in turn will call machine_power_off().
--- arch/parisc/kernel/process.c | 7 +++++-- drivers/parisc/power.c | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/parisc/kernel/process.c +5 -2
@@ -42,6 +42,7 @@#include <linux/module.h> #include <linux/personality.h> #include <linux/ptrace.h> +#include <linux/reboot.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/stddef.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_poweroff (); +/* It seems we have no way to power the system off via * software. The user has to press the button himself. */
@@ -141,7 +144,7 @@ void machine_power_off(void) "Please power this system off now."); } -void (*pm_power_off)(void ) = machine_power_off; +void (*pm_power_off)(void );EXPORT_SYMBOL (pm_power_off);/*
drivers/parisc/power.c +1 -2
@@ -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 (); } } }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 4/16 arm: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/arm/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/process.c +2 -0
@@ -207,6 +207,8 @@ void machine_power_off(void)if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }/*
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 4/16 arm: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/arm/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/process.c +2 -0
@@ -207,6 +207,8 @@ void machine_power_off(void)if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }/*
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 5/16 arm64: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kernel/process.c +2 -0
@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }/*
Signature · 1 line
1.9.1
Re: [RFC PATCH 05/16] arm64: support poweroff through poweroff handler call chain
Quoted 16 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/kernel/process.c +0
-0
arch/arm64/kernel/process.c void machine_power_off(void) · line 161
Quoted 5 lines
arch/arm64/kernel/process.c +2
-0@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
As others already stated, I think we should eventually remove pm_power_off entirely.
Catalin
Guenter Roeck
maintainerRe: [RFC PATCH 05/16] arm64: support poweroff through poweroff handler call chain
Quoted 25 lines · Catalin Marinas
Quoted 16 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/kernel/process.c +0
-0arch/arm64/kernel/process.c void machine_power_off(void) · line 161
Quoted 5 lines
arch/arm64/kernel/process.c +2
-0@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();Acked-by Catalin Marinas <[email protected]>
Quoted 3 lines
As others already stated, I think we should eventually remove
pm_power_offentirely.
Hi Catalin,
yes, already working on it. As suggested by others, I'll move pm_power_off to a central location (no need to declare the same variable for each architecture) and hide the call to it in do_kernel_poweroff() as a first step. You'll see this in the next version of the series. This will make it much easier to remove it later on.
Thanks,
Guenter
Guenter Roeck
maintainerRe: [RFC PATCH 05/16] arm64: support poweroff through poweroff handler call chain
In reply to Catalin MarinasQuoted 25 lines · Catalin Marinas
Quoted 16 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/kernel/process.c +0
-0arch/arm64/kernel/process.c void machine_power_off(void) · line 161
Quoted 5 lines
arch/arm64/kernel/process.c +2
-0@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();Acked-by Catalin Marinas <[email protected]>
Quoted 3 lines
As others already stated, I think we should eventually remove
pm_power_offentirely.
Hi Catalin,
yes, already working on it. As suggested by others, I'll move pm_power_off to a central location (no need to declare the same variable for each architecture) and hide the call to it in do_kernel_poweroff() as a first step. You'll see this in the next version of the series. This will make it much easier to remove it later on.
Thanks,
Guenter
Re: [RFC PATCH 05/16] arm64: support poweroff through poweroff handler call chain
In reply to Guenter RoeckQuoted 16 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm64/kernel/process.c +0
-0
arch/arm64/kernel/process.c void machine_power_off(void) · line 161
Quoted 5 lines
arch/arm64/kernel/process.c +2
-0@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
As others already stated, I think we should eventually remove pm_power_off entirely.
Catalin
Guenter Roeck
maintainerRFC PATCH 5/16 arm64: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/arm64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kernel/process.c +2 -0
@@ -157,6 +157,8 @@ void machine_power_off(void)smp_send_stop ();if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }/*
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 6/16 avr32: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/avr32/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/avr32/kernel/process.c +2 -0
@@ -50,6 +50,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }void machine_restart (char *cmd)
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 6/16 avr32: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/avr32/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/avr32/kernel/process.c +2 -0
@@ -50,6 +50,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }void machine_restart (char *cmd)
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 7/16 c6x: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/c6x/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/c6x/kernel/process.c +2 -0
@@ -75,6 +75,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();halt_loop (); }
Signature · 1 line
1.9.1
Re: [RFC PATCH 07/16] c6x: support poweroff through poweroff handler call chain
Quoted 8 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>Signed-off-by Guenter Roeck <[email protected]>---
Quoted 16 lines
arch/c6x/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/c6x/kernel/process.c +2
-0@@ -75,6 +75,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();halt_loop (); }
Re: [RFC PATCH 07/16] c6x: support poweroff through poweroff handler call chain
In reply to Guenter RoeckQuoted 8 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>Signed-off-by Guenter Roeck <[email protected]>---
Quoted 16 lines
arch/c6x/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)arch/c6x/kernel/process.c +2
-0@@ -75,6 +75,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();halt_loop (); }
Guenter Roeck
maintainerRFC PATCH 7/16 c6x: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/c6x/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/c6x/kernel/process.c +2 -0
@@ -75,6 +75,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();halt_loop (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 8/16 ia64: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/ia64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/ia64/kernel/process.c +2 -0
@@ -677,6 +677,8 @@ machine_power_off (void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();machine_halt (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 8/16 ia64: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/ia64/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/ia64/kernel/process.c +2 -0
@@ -677,6 +677,8 @@ machine_power_off (void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();machine_halt (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 9/16 metag: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/metag/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/metag/kernel/process.c +2 -0
@@ -92,6 +92,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();smp_send_stop ();hard_processor_halt (HALT_OK ); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 9/16 metag: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/metag/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/metag/kernel/process.c +2 -0
@@ -92,6 +92,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();smp_send_stop ();hard_processor_halt (HALT_OK ); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 10/16 mips: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/kernel/reset.c +2 -0
@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }
Signature · 1 line
1.9.1
Re: [RFC PATCH 10/16] mips: support poweroff through poweroff handler call chain
Quoted 15 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Ralf Baechle <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)arch/mips/kernel/reset.c +0
-0
arch/mips/kernel/reset.c void machine_power_off(void) · line 45
Quoted 5 lines
arch/mips/kernel/reset.c +2
-0@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
I'm happy with this as long as in a later version pm_power_off indeed goes away.
Ralf
Guenter Roeck
maintainerRe: [RFC PATCH 10/16] mips: support poweroff through poweroff handler call chain
Quoted 12 lines · Ralf Baechle
Quoted 10 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Ralf Baechle <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 14 lines
arch/mips/kernel/reset.c void machine_power_off(void) · line 45
Quoted 10 lines
arch/mips/kernel/reset.c +2
-0@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();I'm happy with this as long as in a later version
pm_power_offindeed goes away.
Yes, that would be the ultimate goal. Hope we can get there.
Guenter
Guenter Roeck
maintainerRe: [RFC PATCH 10/16] mips: support poweroff through poweroff handler call chain
In reply to Ralf BaechleQuoted 12 lines · Ralf Baechle
Quoted 10 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Ralf Baechle <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 14 lines
arch/mips/kernel/reset.c void machine_power_off(void) · line 45
Quoted 10 lines
arch/mips/kernel/reset.c +2
-0@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();I'm happy with this as long as in a later version
pm_power_offindeed goes away.
Yes, that would be the ultimate goal. Hope we can get there.
Guenter
Re: [RFC PATCH 10/16] mips: support poweroff through poweroff handler call chain
In reply to Guenter RoeckQuoted 15 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Ralf Baechle <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)arch/mips/kernel/reset.c +0
-0
arch/mips/kernel/reset.c void machine_power_off(void) · line 45
Quoted 5 lines
arch/mips/kernel/reset.c +2
-0@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
I'm happy with this as long as in a later version pm_power_off indeed goes away.
Ralf
Guenter Roeck
maintainerRFC PATCH 10/16 mips: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/mips/kernel/reset.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/kernel/reset.c +2 -0
@@ -41,4 +41,6 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 11/16 sh: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/sh/kernel/reboot.c | 2 ++ 1 file changed, 2 insertions(+)
arch/sh/kernel/reboot.c +2 -0
@@ -53,6 +53,8 @@ static void native_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }static void native_machine_halt (void )
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 11/16 sh: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/sh/kernel/reboot.c | 2 ++ 1 file changed, 2 insertions(+)
arch/sh/kernel/reboot.c +2 -0
@@ -53,6 +53,8 @@ static void native_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff (); }static void native_machine_halt (void )
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 12/16 unicore32: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/unicore32/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/unicore32/kernel/process.c +2 -0
@@ -66,6 +66,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();machine_halt (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 12/16 unicore32: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/unicore32/kernel/process.c | 2 ++ 1 file changed, 2 insertions(+)
arch/unicore32/kernel/process.c +2 -0
@@ -66,6 +66,8 @@ void machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();machine_halt (); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 13/16 x86: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/x86/kernel/reboot.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kernel/reboot.c +4 -0
@@ -651,6 +651,10 @@ static void native_machine_power_off(void)if (!reboot_force)machine_shutdown ();pm_power_off (); + }else { +if (!reboot_force) +machine_shutdown (); +do_kernel_poweroff (); }/* A fallback in case there is no PM info available */ tboot_shutdown (TB_SHUTDOWN_HALT );
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 13/16 x86: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/x86/kernel/reboot.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kernel/reboot.c +4 -0
@@ -651,6 +651,10 @@ static void native_machine_power_off(void)if (!reboot_force)machine_shutdown ();pm_power_off (); + }else { +if (!reboot_force) +machine_shutdown (); +do_kernel_poweroff (); }/* A fallback in case there is no PM info available */ tboot_shutdown (TB_SHUTDOWN_HALT );
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 14/16 x86/xen: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/xen/enlighten.c +2 -0
@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();xen_reboot (SHUTDOWN_poweroff); }
Signature · 1 line
1.9.1
Re: [Xen-devel] [RFC PATCH 14/16] x86/xen: support poweroff through poweroff handler call chain
Quoted 19 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/xen/enlighten.c +0
-0
arch/x86/xen/enlighten.c static void xen_machine_power_off(void) · line 1326
Quoted 5 lines
arch/x86/xen/enlighten.c +2
-0@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
Why isn't this if (pm_power_off) check in do_kernel_poweroff()?
That way when you finally remove pm_power_off you need only update one place. A quick skim of the other archs suggest this would work for them too.
David
Guenter Roeck
maintainerRe: [Xen-devel] [RFC PATCH 14/16] x86/xen: support poweroff through poweroff handler call chain
Quoted 28 lines · David Vrabel
Quoted 19 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/xen/enlighten.c +0
-0arch/x86/xen/enlighten.c static void xen_machine_power_off(void) · line 1326
Quoted 5 lines
arch/x86/xen/enlighten.c +2
-0@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();Why isn't this if (
pm_power_off) check indo_kernel_poweroff()?
Quoted 4 lines
That way when you finally remove
pm_power_offyou need only update one place. A quick skim of the other archs suggest this would work for them too.
Good idea. I'll do that for the next version of the patch set.
Guenter
Guenter Roeck
maintainerRe: [RFC PATCH 14/16] x86/xen: support poweroff through poweroff handler call chain
In reply to David VrabelQuoted 28 lines · David Vrabel
Quoted 19 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/xen/enlighten.c +0
-0arch/x86/xen/enlighten.c static void xen_machine_power_off(void) · line 1326
Quoted 5 lines
arch/x86/xen/enlighten.c +2
-0@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();Why isn't this if (
pm_power_off) check indo_kernel_poweroff()?
Quoted 4 lines
That way when you finally remove
pm_power_offyou need only update one place. A quick skim of the other archs suggest this would work for them too.
Good idea. I'll do that for the next version of the patch set.
Guenter
Re: [RFC PATCH 14/16] x86/xen: support poweroff through poweroff handler call chain
In reply to Guenter RoeckQuoted 19 lines · Guenter Roeck
The kernel core now supports a poweroff handler call chain to remove power from the system. Call it if
pm_power_offis set to NULL.Cc Konrad Rzeszutek Wilk <[email protected]>Cc Boris Ostrovsky <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Signed-off-by Guenter Roeck <[email protected]>--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/xen/enlighten.c +0
-0
arch/x86/xen/enlighten.c static void xen_machine_power_off(void) · line 1326
Quoted 5 lines
arch/x86/xen/enlighten.c +2
-0@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();
Why isn't this if (pm_power_off) check in do_kernel_poweroff()?
That way when you finally remove pm_power_off you need only update one place. A quick skim of the other archs suggest this would work for them too.
David
Guenter Roeck
maintainerRFC PATCH 14/16 x86/xen: support poweroff through poweroff handler call chain
In reply to Guenter RoeckThe kernel core now supports a poweroff handler call chain to remove power from the system. Call it if pm_power_off is set to NULL.
--- arch/x86/xen/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/xen/enlighten.c +2 -0
@@ -1322,6 +1322,8 @@ static void xen_machine_power_off(void) {if (pm_power_off)pm_power_off (); +else +do_kernel_poweroff ();xen_reboot (SHUTDOWN_poweroff); }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 15/16 power/reset: restart-poweroff: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of seting pm_power_off directly. Register as poweroff handler of last resort since the driver does not really power off the system but executes a restart.
--- drivers/power/reset/restart-poweroff.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/power/reset/restart-poweroff.c +11 -13
@@ -12,35 +12,33 @@*/ #include <linux/kernel.h> #include <linux/init.h> +#include <linux/notifier.h> #include <linux/platform_device.h> #include <linux/of_platform.h> #include <linux/module.h> #include <linux/reboot.h> -#include <asm/system_misc.h> -static void restart_poweroff_do_poweroff (void ) +static int restart_poweroff_do_poweroff (struct notifier_block *this, +unsigned long unused1,void *unused2) { reboot_mode =REBOOT_HARD ;machine_restart (NULL ); + +return NOTIFY_DONE ; } +static struct notifier_block restart_poweroff_handler = { + .notifier_call = restart_poweroff_do_poweroff, +}; +static int restart_poweroff_probe (struct platform_device *pdev) { -/* If a pm_power_off function has already been added, leave it alone */ -if (pm_power_off !=NULL ) { -dev_err (&pdev->dev, -"pm_power_off function already registered" ); -return -EBUSY ; - } - - pm_power_off = &restart_poweroff_do_poweroff; -return 0 ; +return register_restart_handler (&restart_poweroff_handler); }static int restart_poweroff_remove (struct platform_device *pdev) { -if (pm_power_off == &restart_poweroff_do_poweroff) - pm_power_off =NULL ; +unregister_restart_handler (&restart_poweroff_handler);return 0 ; }
Signature · 1 line
1.9.1
Re: [RFC PATCH 15/16] power/reset: restart-poweroff: Register with kernel poweroff handler
Hi,
Quoted 8 lines · Guenter Roeck
Register with kernel poweroff handler instead of seting
pm_power_offdirectly. Register as poweroff handler of last resort since the driver does not really power off the system but executes a restart.Cc Sebastian Reichel <[email protected]>Cc Dmitry Eremin-Solenikov <[email protected]>Cc David Woodhouse <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141003/3e06131f/attachment.sig>
Re: [RFC PATCH 15/16] power/reset: restart-poweroff: Register with kernel poweroff handler
In reply to Guenter RoeckHi,
Quoted 8 lines · Guenter Roeck
Register with kernel poweroff handler instead of seting
pm_power_offdirectly. Register as poweroff handler of last resort since the driver does not really power off the system but executes a restart.Cc Sebastian Reichel <[email protected]>Cc Dmitry Eremin-Solenikov <[email protected]>Cc David Woodhouse <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
-- Sebastian
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Guenter Roeck
maintainerRFC PATCH 15/16 power/reset: restart-poweroff: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of seting pm_power_off directly. Register as poweroff handler of last resort since the driver does not really power off the system but executes a restart.
--- drivers/power/reset/restart-poweroff.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/power/reset/restart-poweroff.c +11 -13
@@ -12,35 +12,33 @@*/ #include <linux/kernel.h> #include <linux/init.h> +#include <linux/notifier.h> #include <linux/platform_device.h> #include <linux/of_platform.h> #include <linux/module.h> #include <linux/reboot.h> -#include <asm/system_misc.h> -static void restart_poweroff_do_poweroff (void ) +static int restart_poweroff_do_poweroff (struct notifier_block *this, +unsigned long unused1,void *unused2) { reboot_mode =REBOOT_HARD ;machine_restart (NULL ); + +return NOTIFY_DONE ; } +static struct notifier_block restart_poweroff_handler = { + .notifier_call = restart_poweroff_do_poweroff, +}; +static int restart_poweroff_probe (struct platform_device *pdev) { -/* If a pm_power_off function has already been added, leave it alone */ -if (pm_power_off !=NULL ) { -dev_err (&pdev->dev, -"pm_power_off function already registered" ); -return -EBUSY ; - } - - pm_power_off = &restart_poweroff_do_poweroff; -return 0 ; +return register_restart_handler (&restart_poweroff_handler); }static int restart_poweroff_remove (struct platform_device *pdev) { -if (pm_power_off == &restart_poweroff_do_poweroff) - pm_power_off =NULL ; +unregister_restart_handler (&restart_poweroff_handler);return 0 ; }
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 16/16 mfd: palmas: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
--- drivers/mfd/palmas.c | 30 +++++++++++++++++------------- include/linux/mfd/palmas.h | 3 +++ 2 files changed, 20 insertions(+), 13 deletions(-)
drivers/mfd/palmas.c +17 -13
@@ -19,6 +19,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/reboot.h> #include <linux/regmap.h> #include <linux/err.h> #include <linux/mfd/core.h>
@@ -425,20 +426,18 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, "ti,system-power-controller"); } -static struct palmas *palmas_dev; -static void palmas_power_off (void ) +static int palmas_power_off (struct notifier_block *this,unsigned long unused1, +void *unused2) { + struct palmas *palmas = container_of(this, struct palmas, poweroff_nb);unsigned int addr;int ret, slave; -if (!palmas_dev) -return ; - slave =PALMAS_BASE_TO_SLAVE (PALMAS_PMU_CONTROL_BASE ); addr =PALMAS_BASE_TO_REG (PALMAS_PMU_CONTROL_BASE ,PALMAS_DEV_CTRL ); ret =regmap_update_bits ( - palmas_dev->regmap[slave], + palmas->regmap[slave], addr,PALMAS_DEV_CTRL_DEV_ON ,0 );
@@ -446,6 +445,8 @@ static void palmas_power_off(void)if (ret)pr_err ("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n" , __func__, ret); + +return NOTIFY_DONE ; }static unsigned int palmas_features =PALMAS_PMIC_FEATURE_SMPS10_BOOST ;
@@ -668,9 +669,15 @@ no_irq: ret =of_platform_populate (node,NULL ,NULL , &i2c->dev);if (ret <0 ) { goto err_irq; - }else if (pdata->pm_off && !pm_power_off) { - palmas_dev = palmas; - pm_power_off = palmas_power_off; + }else if (pdata->pm_off) { + palmas->poweroff_nb.notifier_call = palmas_power_off; + palmas->poweroff_nb.priority =128 ; + ret =register_poweroff_handler (&palmas->poweroff_nb); +if (ret) { +dev_err (palmas->dev, +"cannot register poweroff handler" ); + ret =0 ; + } } }
@@ -698,10 +705,7 @@ static int palmas_i2c_remove(struct i2c_client *i2c)i2c_unregister_device (palmas->i2c_clients[i]); } -if (palmas == palmas_dev) { - pm_power_off =NULL ; - palmas_dev =NULL ; - } +unregister_poweroff_handler (&palmas->poweroff_nb);return 0 ; }
include/linux/mfd/palmas.h +3 -0
@@ -18,6 +18,7 @@#include <linux/usb/otg.h> #include <linux/leds.h> +#include <linux/notifier.h> #include <linux/regmap.h> #include <linux/regulator/driver.h> #include <linux/extcon.h>
@@ -68,6 +69,8 @@ struct palmas {struct i2c_client *i2c_clients[PALMAS_NUM_CLIENTS ];struct regmap *regmap[PALMAS_NUM_CLIENTS ]; +struct notifier_block poweroff_nb; +/* Stored chip id */ int id;
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRFC PATCH 16/16 mfd: palmas: Register with kernel poweroff handler
In reply to Guenter RoeckRegister with kernel poweroff handler instead of setting pm_power_off directly.
--- drivers/mfd/palmas.c | 30 +++++++++++++++++------------- include/linux/mfd/palmas.h | 3 +++ 2 files changed, 20 insertions(+), 13 deletions(-)
drivers/mfd/palmas.c +17 -13
@@ -19,6 +19,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/reboot.h> #include <linux/regmap.h> #include <linux/err.h> #include <linux/mfd/core.h>
@@ -425,20 +426,18 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, "ti,system-power-controller"); } -static struct palmas *palmas_dev; -static void palmas_power_off (void ) +static int palmas_power_off (struct notifier_block *this,unsigned long unused1, +void *unused2) { + struct palmas *palmas = container_of(this, struct palmas, poweroff_nb);unsigned int addr;int ret, slave; -if (!palmas_dev) -return ; - slave =PALMAS_BASE_TO_SLAVE (PALMAS_PMU_CONTROL_BASE ); addr =PALMAS_BASE_TO_REG (PALMAS_PMU_CONTROL_BASE ,PALMAS_DEV_CTRL ); ret =regmap_update_bits ( - palmas_dev->regmap[slave], + palmas->regmap[slave], addr,PALMAS_DEV_CTRL_DEV_ON ,0 );
@@ -446,6 +445,8 @@ static void palmas_power_off(void)if (ret)pr_err ("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n" , __func__, ret); + +return NOTIFY_DONE ; }static unsigned int palmas_features =PALMAS_PMIC_FEATURE_SMPS10_BOOST ;
@@ -668,9 +669,15 @@ no_irq: ret =of_platform_populate (node,NULL ,NULL , &i2c->dev);if (ret <0 ) { goto err_irq; - }else if (pdata->pm_off && !pm_power_off) { - palmas_dev = palmas; - pm_power_off = palmas_power_off; + }else if (pdata->pm_off) { + palmas->poweroff_nb.notifier_call = palmas_power_off; + palmas->poweroff_nb.priority =128 ; + ret =register_poweroff_handler (&palmas->poweroff_nb); +if (ret) { +dev_err (palmas->dev, +"cannot register poweroff handler" ); + ret =0 ; + } } }
@@ -698,10 +705,7 @@ static int palmas_i2c_remove(struct i2c_client *i2c)i2c_unregister_device (palmas->i2c_clients[i]); } -if (palmas == palmas_dev) { - pm_power_off =NULL ; - palmas_dev =NULL ; - } +unregister_poweroff_handler (&palmas->poweroff_nb);return 0 ; }
include/linux/mfd/palmas.h +3 -0
@@ -18,6 +18,7 @@#include <linux/usb/otg.h> #include <linux/leds.h> +#include <linux/notifier.h> #include <linux/regmap.h> #include <linux/regulator/driver.h> #include <linux/extcon.h>
@@ -68,6 +69,8 @@ struct palmas {struct i2c_client *i2c_clients[PALMAS_NUM_CLIENTS ];struct regmap *regmap[PALMAS_NUM_CLIENTS ]; +struct notifier_block poweroff_nb; +/* Stored chip id */ int id;
Signature · 1 line
1.9.1