efi/reboot: Add generic wrapper around EfiResetSystem()
authorMatt Fleming <matt.fleming@intel.com>
Fri, 13 Jun 2014 11:22:22 +0000 (12:22 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 18 Jul 2014 20:23:51 +0000 (21:23 +0100)
Implement efi_reboot(), which is really just a wrapper around the
EfiResetSystem() EFI runtime service, but it does at least allow us to
funnel all callers through a single location.

It also simplifies the callsites since users no longer need to check to
see whether EFI_RUNTIME_SERVICES are enabled.

Cc: Tony Luck <tony.luck@intel.com>
Tested-by: Mark Salter <msalter@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
arch/ia64/kernel/process.c
arch/x86/kernel/reboot.c
drivers/firmware/efi/Makefile
drivers/firmware/efi/reboot.c [new file with mode: 0644]
include/linux/efi.h

index 55d4ba47a907acd766541c9b8f1106dbae49dba3..deed6fa96bb054c50c6a12bdf83fe57028a5eb1d 100644 (file)
@@ -662,7 +662,7 @@ void
 machine_restart (char *restart_cmd)
 {
        (void) notify_die(DIE_MACHINE_RESTART, restart_cmd, NULL, 0, 0, 0);
-       (*efi.reset_system)(EFI_RESET_WARM, 0, 0, NULL);
+       efi_reboot(REBOOT_WARM, NULL);
 }
 
 void
index 52b1157c53eb7f275b22d4a74def7daced321a80..09e709fd1830a83ae0112fde75951de7db57d45c 100644 (file)
@@ -528,11 +528,7 @@ static void native_machine_emergency_restart(void)
                        break;
 
                case BOOT_EFI:
-                       if (efi_enabled(EFI_RUNTIME_SERVICES))
-                               efi.reset_system(reboot_mode == REBOOT_WARM ?
-                                                EFI_RESET_WARM :
-                                                EFI_RESET_COLD,
-                                                EFI_SUCCESS, 0, NULL);
+                       efi_reboot(reboot_mode, NULL);
                        reboot_type = BOOT_BIOS;
                        break;
 
index a204d1474cec130cdc2c6a93fc25566fa28cb43b..d8be608a9f3be733bf4d56a1e360ecc3c5471e7b 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Makefile for linux kernel
 #
-obj-$(CONFIG_EFI)                      += efi.o vars.o
+obj-$(CONFIG_EFI)                      += efi.o vars.o reboot.o
 obj-$(CONFIG_EFI_VARS)                 += efivars.o
 obj-$(CONFIG_EFI_VARS_PSTORE)          += efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)                        += cper.o
diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c
new file mode 100644 (file)
index 0000000..81bf925
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 Intel Corporation; author Matt Fleming
+ * Copyright (c) 2014 Red Hat, Inc., Mark Salter <msalter@redhat.com>
+ */
+#include <linux/efi.h>
+#include <linux/reboot.h>
+
+void efi_reboot(enum reboot_mode reboot_mode, const char *__unused)
+{
+       int efi_mode;
+
+       if (!efi_enabled(EFI_RUNTIME_SERVICES))
+               return;
+
+       switch (reboot_mode) {
+       case REBOOT_WARM:
+       case REBOOT_SOFT:
+               efi_mode = EFI_RESET_WARM;
+               break;
+       default:
+               efi_mode = EFI_RESET_COLD;
+               break;
+       }
+
+       efi.reset_system(efi_mode, EFI_SUCCESS, 0, NULL);
+}
index 3a64f2f85821a2729aab184e7b51232d2b360f57..e6980ba528ec4b58142139ad3fbed121f2a30f35 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/ioport.h>
 #include <linux/pfn.h>
 #include <linux/pstore.h>
+#include <linux/reboot.h>
 
 #include <asm/page.h>
 
@@ -928,11 +929,14 @@ static inline bool efi_enabled(int feature)
 {
        return test_bit(feature, &efi.flags) != 0;
 }
+extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
 #else
 static inline bool efi_enabled(int feature)
 {
        return false;
 }
+static inline void
+efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {}
 #endif
 
 /*
This page took 0.029855 seconds and 5 git commands to generate.