mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
kernel/reboot: Wrap legacy power-off callbacks into sys-off handlers
Wrap legacy power-off callbacks into sys-off handlers in order to support co-existence of both legacy and new callbacks while we're in process of upgrading legacy callbacks to the new API. 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
232edc2f72
commit
7b9a3de9ff
@ -463,6 +463,47 @@ int devm_register_sys_off_handler(struct device *dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_register_sys_off_handler);
|
||||
|
||||
static int legacy_pm_power_off_prepare(struct sys_off_data *data)
|
||||
{
|
||||
if (pm_power_off_prepare)
|
||||
pm_power_off_prepare();
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int legacy_pm_power_off(struct sys_off_data *data)
|
||||
{
|
||||
if (pm_power_off)
|
||||
pm_power_off();
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register sys-off handlers for legacy PM callbacks. This allows legacy
|
||||
* PM callbacks co-exist with the new sys-off API.
|
||||
*
|
||||
* TODO: Remove legacy handlers once all legacy PM users will be switched
|
||||
* to the sys-off based APIs.
|
||||
*/
|
||||
static int __init legacy_pm_init(void)
|
||||
{
|
||||
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF_PREPARE,
|
||||
SYS_OFF_PRIO_DEFAULT,
|
||||
legacy_pm_power_off_prepare, NULL);
|
||||
|
||||
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_DEFAULT,
|
||||
legacy_pm_power_off, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
core_initcall(legacy_pm_init);
|
||||
|
||||
static void do_kernel_power_off_prepare(void)
|
||||
{
|
||||
blocking_notifier_call_chain(&power_off_prep_handler_list, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* kernel_power_off - power_off the system
|
||||
*
|
||||
@ -471,8 +512,7 @@ EXPORT_SYMBOL_GPL(devm_register_sys_off_handler);
|
||||
void kernel_power_off(void)
|
||||
{
|
||||
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
|
||||
if (pm_power_off_prepare)
|
||||
pm_power_off_prepare();
|
||||
do_kernel_power_off_prepare();
|
||||
migrate_to_reboot_cpu();
|
||||
syscore_shutdown();
|
||||
pr_emerg("Power down\n");
|
||||
|
Loading…
Reference in New Issue
Block a user