Skip to content

Commit 28d5402

Browse files
Lee, Chun-YiMatt Fleming
authored andcommitted
efi: Autoload efivars
The original patch is from Ben Hutchings's contribution to debian kernel. Got Ben's permission to remove the code of efi-pstore.c and send to linux-efi: https://github.com/BlankOn/linux-debian/blob/master/debian/patches/features/all/efi-autoload-efivars.patch efivars is generally useful to have on EFI systems, and in some cases it may be impossible to load it after a kernel upgrade in order to complete a boot loader update. At the same time we don't want to waste memory on non-EFI systems by making them built-in. Instead, give them module aliases as if they are platform drivers, and register a corresponding platform device whenever EFI runtime services are available. This should trigger udev to load them. Signed-off-by: Lee, Chun-Yi <jlee@suse.com> Cc: Ben Hutchings <ben@decadent.org.uk> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
1 parent 82f990a commit 28d5402

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎drivers/firmware/efi/efi.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/of.h>
2424
#include <linux/of_fdt.h>
2525
#include <linux/io.h>
26+
#include <linux/platform_device.h>
2627

2728
struct efi __read_mostly efi = {
2829
.mps = EFI_INVALID_TABLE_ADDR,
@@ -324,6 +325,20 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
324325
return 0;
325326
}
326327

328+
#ifdef CONFIG_EFI_VARS_MODULE
329+
static int __init efi_load_efivars(void)
330+
{
331+
struct platform_device *pdev;
332+
333+
if (!efi_enabled(EFI_RUNTIME_SERVICES))
334+
return 0;
335+
336+
pdev = platform_device_register_simple("efivars", 0, NULL, 0);
337+
return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
338+
}
339+
device_initcall(efi_load_efivars);
340+
#endif
341+
327342
#ifdef CONFIG_EFI_PARAMS_FROM_FDT
328343

329344
#define UEFI_PARAM(name, prop, field) \

‎drivers/firmware/efi/efivars.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch@Dell.com>");
7878
MODULE_DESCRIPTION("sysfs interface to EFI Variables");
7979
MODULE_LICENSE("GPL");
8080
MODULE_VERSION(EFIVARS_VERSION);
81+
MODULE_ALIAS("platform:efivars");
8182

8283
LIST_HEAD(efivar_sysfs_list);
8384
EXPORT_SYMBOL_GPL(efivar_sysfs_list);

0 commit comments

Comments
 (0)