efi: efivars: drop kobject from efivars_register()
Subsystems (2)
cover efi: efivars: drop kobject from efivars_register()
Since the removal of the deprecated efivars sysfs interface there are no users of the efivars kobject, which can be removed.
Included is also a related patch changing the return type of efivar_supports_writes() to match the new efivar_is_available() function.
Note that I intend to use efivar_is_available() in a driver with optional EFI support (hence the dummy implementation) and the removal of the kobject will simplify the upcoming Qualcomm UEFI Secure Application driver somewhat too.
Johan
Johan Hovold (2):
efi: efivars: drop kobject from efivars_register()
efi: efivars: make efivar_supports_writes() return bool
drivers/firmware/efi/efi.c | 2 +- drivers/firmware/efi/vars.c | 21 +++++++-------------- drivers/firmware/google/gsmi.c | 2 +- fs/efivarfs/super.c | 2 +- include/linux/efi.h | 13 ++++++++----- 5 files changed, 18 insertions(+), 22 deletions(-)
Signature · 1 line
2.38.2
PATCH 1/2 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().
--- drivers/firmware/efi/efi.c | 2 +- drivers/firmware/efi/vars.c | 19 ++++++------------- drivers/firmware/google/gsmi.c | 2 +- fs/efivarfs/super.c | 2 +- include/linux/efi.h | 11 +++++++---- 5 files changed, 16 insertions(+), 20 deletions(-)
drivers/firmware/efi/efi.c +1 -1
@@ -197,7 +197,7 @@ static int generic_ops_register(void) generic_ops.set_variable = efi.set_variable; generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; } -return efivars_register (&generic_efivars, &generic_ops, efi_kobj); +return efivars_register (&generic_efivars, &generic_ops); }static void generic_ops_unregister (void )
drivers/firmware/efi/vars.c +6 -13
@@ -40,37 +40,30 @@ static efi_status_t check_var_size(bool nonblocking, u32 attributes, }/** -* efivars_kobject - get the kobject for the registered efivars +* efivar_is_available - check if efivars is available * -* If efivars_register() has not been called we return NULL, -* otherwise return the kobject used at registration time. +* @return true iff evivars is currently registered */ -struct kobject *efivars_kobject (void ) +bool efivar_is_available (void ) { -if (!__efivars) -return NULL ; - -return __efivars->kobject; +return __efivars !=NULL ; } -EXPORT_SYMBOL_GPL (efivars_kobject); +EXPORT_SYMBOL_GPL (efivar_is_available);/** * efivars_register - register an efivars * @efivars: efivars to register * @ops: efivars operations -* @kobject: @efivars-specific kobject * * Only a single efivars can be registered at any time. */ int efivars_register (struct efivars *efivars, -const struct efivar_operations *ops, -struct kobject *kobject) +const struct efivar_operations *ops) {if (down_interruptible (&efivars_lock))return -EINTR ; efivars->ops = ops; - efivars->kobject = kobject; __efivars = efivars;
drivers/firmware/google/gsmi.c +1 -1
@@ -1029,7 +1029,7 @@ static __init int gsmi_init(void) }#ifdef CONFIG_EFI - ret =efivars_register (&efivars, &efivar_ops, gsmi_kobj); + ret =efivars_register (&efivars, &efivar_ops);if (ret) {printk (KERN_INFO "gsmi: Failed to register efivars\n" );sysfs_remove_files (gsmi_kobj, gsmi_attrs);
fs/efivarfs/super.c +1 -1
@@ -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);
include/linux/efi.h +7 -4
@@ -1039,7 +1039,6 @@ struct efivar_operations {struct efivars {struct kset *kset; -struct kobject *kobject;const struct efivar_operations *ops; };
@@ -1053,10 +1052,14 @@ struct efivars {#define EFI_VAR_NAME_LEN 1024int efivars_register (struct efivars *efivars, -const struct efivar_operations *ops, -struct kobject *kobject); +const struct efivar_operations *ops);int efivars_unregister (struct efivars *efivars); -struct kobject *efivars_kobject (void ); + +#ifdef CONFIG_EFI +bool efivar_is_available (void ); +#else +static inline bool efivar_is_available (void ) {return false; } +#endif int efivar_supports_writes (void );
Signature · 1 line
2.38.2
PATCH 2/2 efi: efivars: make efivar_supports_writes() return bool
In reply to Johan HovoldFor consistency with the new efivar_is_available() function, change the return type of efivar_supports_writes() to bool.
--- drivers/firmware/efi/vars.c | 2 +- include/linux/efi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/vars.c +1 -1
@@ -110,7 +110,7 @@ int efivars_unregister(struct efivars *efivars) }EXPORT_SYMBOL_GPL (efivars_unregister); -int efivar_supports_writes (void ) +bool efivar_supports_writes (void ) {return __efivars && __efivars->ops->set_variable; }
include/linux/efi.h +1 -1
@@ -1061,7 +1061,7 @@ bool efivar_is_available(void);static inline bool efivar_is_available (void ) {return false; }#endif -int efivar_supports_writes (void ); +bool efivar_supports_writes (void );int efivar_lock (void );int efivar_trylock (void );
Signature · 1 line
2.38.2
Ard Biesheuvel
maintainerQuoted 13 lines · Johan Hovold
Since the removal of the deprecated efivars sysfs interface there are no users of the efivars kobject, which can be removed.
Included is also a related patch changing the return type of
efivar_supports_writes()to match the newefivar_is_available()function.Note that I intend to use
efivar_is_available()in a driver with optional EFI support (hence the dummy implementation) and the removal of the kobject will simplify the upcoming Qualcomm UEFI Secure Application driver somewhat too.
Quoted 7 lines
Johan
Johan Hovold (2):
efi: efivars: drop kobject fromefivars_register()
efi: efivars: makeefivar_supports_writes()return bool
Thanks, I've queued these up now
Quoted 10 lines
drivers/firmware/efi/efi.c | 2 +- drivers/firmware/efi/vars.c | 21 +++++++-------------- drivers/firmware/google/gsmi.c | 2 +- fs/efivarfs/super.c | 2 +- include/linux/efi.h | 13 ++++++++----- 5 files changed, 18 insertions(+), 22 deletions(-)--
2.38.2