ACPI: power: Switch to sys-off handler API
Switch to sys-off API that replaces legacy pm_power_off callbacks, allowing us to remove global pm_* variables and support chaining of all restart and power-off modes consistently. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
bf8d73b934
commit
98f30d0ecf
1 changed files with 12 additions and 4 deletions
|
@ -1023,20 +1023,22 @@ static void acpi_sleep_hibernate_setup(void)
|
||||||
static inline void acpi_sleep_hibernate_setup(void) {}
|
static inline void acpi_sleep_hibernate_setup(void) {}
|
||||||
#endif /* !CONFIG_HIBERNATION */
|
#endif /* !CONFIG_HIBERNATION */
|
||||||
|
|
||||||
static void acpi_power_off_prepare(void)
|
static int acpi_power_off_prepare(struct sys_off_data *data)
|
||||||
{
|
{
|
||||||
/* Prepare to power off the system */
|
/* Prepare to power off the system */
|
||||||
acpi_sleep_prepare(ACPI_STATE_S5);
|
acpi_sleep_prepare(ACPI_STATE_S5);
|
||||||
acpi_disable_all_gpes();
|
acpi_disable_all_gpes();
|
||||||
acpi_os_wait_events_complete();
|
acpi_os_wait_events_complete();
|
||||||
|
return NOTIFY_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_power_off(void)
|
static int acpi_power_off(struct sys_off_data *data)
|
||||||
{
|
{
|
||||||
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
|
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
|
||||||
pr_debug("%s called\n", __func__);
|
pr_debug("%s called\n", __func__);
|
||||||
local_irq_disable();
|
local_irq_disable();
|
||||||
acpi_enter_sleep_state(ACPI_STATE_S5);
|
acpi_enter_sleep_state(ACPI_STATE_S5);
|
||||||
|
return NOTIFY_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __init acpi_sleep_init(void)
|
int __init acpi_sleep_init(void)
|
||||||
|
@ -1055,8 +1057,14 @@ int __init acpi_sleep_init(void)
|
||||||
|
|
||||||
if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
|
if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
|
||||||
sleep_states[ACPI_STATE_S5] = 1;
|
sleep_states[ACPI_STATE_S5] = 1;
|
||||||
pm_power_off_prepare = acpi_power_off_prepare;
|
|
||||||
pm_power_off = acpi_power_off;
|
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF_PREPARE,
|
||||||
|
SYS_OFF_PRIO_FIRMWARE,
|
||||||
|
acpi_power_off_prepare, NULL);
|
||||||
|
|
||||||
|
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
|
||||||
|
SYS_OFF_PRIO_FIRMWARE,
|
||||||
|
acpi_power_off, NULL);
|
||||||
} else {
|
} else {
|
||||||
acpi_no_s5 = true;
|
acpi_no_s5 = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue