aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2014-10-23 17:20:37 -0400
committerMatt Fleming <matt.fleming@intel.com>2014-11-11 17:22:27 -0500
commitaf5a29aee4d1e5b5fbfbaf45cb097f9c6257c7b8 (patch)
treea0c6e4f0afe9c85bc1d014a0f72b76f47395f37e
parentcac7f2429872d3733dc3f9915857b1691da2eb2f (diff)
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 <jk@ozlabs.org> Cc: Matthew Garrett <matthew.garrett@nebula.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--fs/efivarfs/super.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 0a48886e069c..6dad1176ec52 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -236,6 +236,7 @@ static void efivarfs_kill_sb(struct super_block *sb)
236} 236}
237 237
238static struct file_system_type efivarfs_type = { 238static struct file_system_type efivarfs_type = {
239 .owner = THIS_MODULE,
239 .name = "efivarfs", 240 .name = "efivarfs",
240 .mount = efivarfs_mount, 241 .mount = efivarfs_mount,
241 .kill_sb = efivarfs_kill_sb, 242 .kill_sb = efivarfs_kill_sb,
@@ -244,17 +245,23 @@ static struct file_system_type efivarfs_type = {
244static __init int efivarfs_init(void) 245static __init int efivarfs_init(void)
245{ 246{
246 if (!efi_enabled(EFI_RUNTIME_SERVICES)) 247 if (!efi_enabled(EFI_RUNTIME_SERVICES))
247 return 0; 248 return -ENODEV;
248 249
249 if (!efivars_kobject()) 250 if (!efivars_kobject())
250 return 0; 251 return -ENODEV;
251 252
252 return register_filesystem(&efivarfs_type); 253 return register_filesystem(&efivarfs_type);
253} 254}
254 255
256static __exit void efivarfs_exit(void)
257{
258 unregister_filesystem(&efivarfs_type);
259}
260
255MODULE_AUTHOR("Matthew Garrett, Jeremy Kerr"); 261MODULE_AUTHOR("Matthew Garrett, Jeremy Kerr");
256MODULE_DESCRIPTION("EFI Variable Filesystem"); 262MODULE_DESCRIPTION("EFI Variable Filesystem");
257MODULE_LICENSE("GPL"); 263MODULE_LICENSE("GPL");
258MODULE_ALIAS_FS("efivarfs"); 264MODULE_ALIAS_FS("efivarfs");
259 265
260module_init(efivarfs_init); 266module_init(efivarfs_init);
267module_exit(efivarfs_exit);