Skip to content
Snippets Groups Projects
Commit ac2b2c47 authored by Dmitry Osipenko's avatar Dmitry Osipenko
Browse files

firmware: efi: Switch to sys-off handler


Use sys-off handler that replaces global pm_power_off variable and allows
to register multiple power-off handlers.

Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
parent 845a8dcd
Branches
Tags
No related merge requests found
......@@ -6,8 +6,6 @@
#include <linux/efi.h>
#include <linux/reboot.h>
static void (*orig_pm_power_off)(void);
int efi_reboot_quirk_mode = -1;
void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
......@@ -51,26 +49,28 @@ bool __weak efi_poweroff_required(void)
return false;
}
static void efi_power_off(void)
static void efi_power_off(struct power_off_data *data)
{
efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
/*
* The above call should not return, if it does fall back to
* the original power off method (typically ACPI poweroff).
*/
if (orig_pm_power_off)
orig_pm_power_off();
}
static struct sys_off_handler efi_sys_off = {
.power_off_priority = POWEROFF_PRIO_FIRMWARE + 1,
.power_off_chaining_allowed = true,
.power_off_cb = efi_power_off,
};
static int __init efi_shutdown_init(void)
{
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_RESET_SYSTEM))
return -ENODEV;
if (efi_poweroff_required()) {
orig_pm_power_off = pm_power_off;
pm_power_off = efi_power_off;
}
if (efi_poweroff_required())
register_sys_off_handler(&efi_sys_off);
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment