Skip to content

Commit

Permalink
efivarfs: Allow unloading when build as module
Browse files Browse the repository at this point in the history
There is no need to keep the module loaded when it serves no function in
case the EFI runtime services are disabled. Return an error in this case
so loading the module will fail.

Also supply a module_exit function to allow unloading the module.

Last, but not least, set the owner of the file_system_type struct.

Cc: Jeremy Kerr <[email protected]>
Cc: Matthew Garrett <[email protected]>
Signed-off-by: Mathias Krause <[email protected]>
Signed-off-by: Matt Fleming <[email protected]>
  • Loading branch information
minipli authored and Matt Fleming committed Nov 11, 2014
1 parent cac7f24 commit af5a29a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions fs/efivarfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static void efivarfs_kill_sb(struct super_block *sb)
}

static struct file_system_type efivarfs_type = {
.owner = THIS_MODULE,
.name = "efivarfs",
.mount = efivarfs_mount,
.kill_sb = efivarfs_kill_sb,
Expand All @@ -244,17 +245,23 @@ static struct file_system_type efivarfs_type = {
static __init int efivarfs_init(void)
{
if (!efi_enabled(EFI_RUNTIME_SERVICES))
return 0;
return -ENODEV;

if (!efivars_kobject())
return 0;
return -ENODEV;

return register_filesystem(&efivarfs_type);
}

static __exit void efivarfs_exit(void)
{
unregister_filesystem(&efivarfs_type);
}

MODULE_AUTHOR("Matthew Garrett, Jeremy Kerr");
MODULE_DESCRIPTION("EFI Variable Filesystem");
MODULE_LICENSE("GPL");
MODULE_ALIAS_FS("efivarfs");

module_init(efivarfs_init);
module_exit(efivarfs_exit);

0 comments on commit af5a29a

Please sign in to comment.