From ade7fd908d710d0ab865c273df782c75528636ef Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 17 Jan 2023 13:43:09 +0100 Subject: efi: efivars: drop kobject from efivars_register() Since commit 0f5b2c69a4cb ("efi: vars: Remove deprecated 'efivars' sysfs interface") and the removal of the sysfs interface there are no users of the efivars kobject. Drop the kobject argument from efivars_register() and add a new efivar_is_available() helper in favour of the old efivars_kobject(). Note that the new helper uses the prefix 'efivar' (i.e. without an 's') for consistency with efivar_supports_writes() and the rest of the interface (except the registration functions). For the benefit of drivers with optional EFI support, also provide a dummy implementation of efivar_is_available(). Signed-off-by: Johan Hovold Signed-off-by: Ard Biesheuvel --- fs/efivarfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/efivarfs') diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 07e82e246666..f72c529c8ec3 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -256,7 +256,7 @@ static struct file_system_type efivarfs_type = { static __init int efivarfs_init(void) { - if (!efivars_kobject()) + if (!efivar_is_available()) return -ENODEV; return register_filesystem(&efivarfs_type); -- cgit v1.2.3 From 301de9a2055357375a4e1053d9df0f8f3467ff00 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 19 Jan 2023 17:42:53 +0100 Subject: efivarfs: always register filesystem The efivar ops are typically registered at subsys init time so that they are available when efivarfs is registered at module init time. Other efivars implementations, such as Google SMI, exist and can currently be built as modules which means that efivar may not be available when efivarfs is initialised. Move the efivar availability check from module init to when the filesystem is mounted to allow late registration of efivars. Signed-off-by: Johan Hovold Signed-off-by: Ard Biesheuvel --- fs/efivarfs/super.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'fs/efivarfs') diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index f72c529c8ec3..482d612b716b 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -194,6 +194,9 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc) struct dentry *root; int err; + if (!efivar_is_available()) + return -EOPNOTSUPP; + sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; @@ -243,6 +246,9 @@ static void efivarfs_kill_sb(struct super_block *sb) { kill_litter_super(sb); + if (!efivar_is_available()) + return; + /* Remove all entries and destroy */ efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); } @@ -256,9 +262,6 @@ static struct file_system_type efivarfs_type = { static __init int efivarfs_init(void) { - if (!efivar_is_available()) - return -ENODEV; - return register_filesystem(&efivarfs_type); } -- cgit v1.2.3