Skip to contentSkip to conversation

efivarfs: allow unloading when build as module

PATCH Applied Mathias Krause 2 participants 2 messages Oct 23, 2014 – Nov 4, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efivarfs: allow unloading when build as module

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 <matthew.garrett-05XSO3Yj/[email protected]>
---
 fs/efivarfs/super.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/efivarfs/super.c +9 -2
index 0a48886e069c..6dad1176ec52 100644
@@ -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,
@@ -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);
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1414099237-19081-1-git-send-email-minipli-gM/[email protected]

Applied
#2 lore raw
Quoted 6 lines · Mathias Krause

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.

Quoted 8 lines

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

Cc Jeremy Kerr <[email protected]>
Cc Matthew Garrett <matthew.garrett-05XSO3Yj/[email protected]>
---
 fs/efivarfs/super.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Thanks, applied.

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center