Merge tag 'arm-dt-6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / firmware / efi / reboot.c
index 73089a2..ceae84c 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/efi.h>
 #include <linux/reboot.h>
 
-static void (*orig_pm_power_off)(void);
+static struct sys_off_handler *efi_sys_off_handler;
 
 int efi_reboot_quirk_mode = -1;
 
@@ -51,15 +51,11 @@ bool __weak efi_poweroff_required(void)
        return false;
 }
 
-static void efi_power_off(void)
+static int efi_power_off(struct sys_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();
+
+       return NOTIFY_DONE;
 }
 
 static int __init efi_shutdown_init(void)
@@ -68,8 +64,13 @@ static int __init efi_shutdown_init(void)
                return -ENODEV;
 
        if (efi_poweroff_required()) {
-               orig_pm_power_off = pm_power_off;
-               pm_power_off = efi_power_off;
+               /* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off */
+               efi_sys_off_handler =
+                       register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
+                                                SYS_OFF_PRIO_FIRMWARE + 1,
+                                                efi_power_off, NULL);
+               if (IS_ERR(efi_sys_off_handler))
+                       return PTR_ERR(efi_sys_off_handler);
        }
 
        return 0;