Skip to content

Commit 62cb7ab

Browse files
krzkardbiesheuvel
authored andcommitted
efi: stmm: Constify struct efivar_operations
The 'struct efivar_operations' is not modified by the driver after initialization, so it should follow typical practice of being static const for increased code safety and readability. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent e00ac9e commit 62cb7ab

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/firmware/efi/stmm/tee_stmm_efi.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "mm_communication.h"
1515

1616
static struct efivars tee_efivars;
17-
static struct efivar_operations tee_efivar_ops;
1817

1918
static size_t max_buffer_size; /* comm + var + func + data */
2019
static size_t max_payload_size; /* func + data */
@@ -520,6 +519,15 @@ static void tee_stmm_restore_efivars_generic_ops(void)
520519
efivars_generic_ops_register();
521520
}
522521

522+
static const struct efivar_operations tee_efivar_ops = {
523+
.get_variable = tee_get_variable,
524+
.get_next_variable = tee_get_next_variable,
525+
.set_variable = tee_set_variable,
526+
.set_variable_nonblocking = tee_set_variable_nonblocking,
527+
.query_variable_store = efi_query_variable_store,
528+
.query_variable_info = tee_query_variable_info,
529+
};
530+
523531
static int tee_stmm_efi_probe(struct tee_client_device *tee_dev)
524532
{
525533
struct device *dev = &tee_dev->dev;
@@ -558,13 +566,6 @@ static int tee_stmm_efi_probe(struct tee_client_device *tee_dev)
558566
MM_VARIABLE_COMMUNICATE_SIZE +
559567
max_payload_size;
560568

561-
tee_efivar_ops.get_variable = tee_get_variable;
562-
tee_efivar_ops.get_next_variable = tee_get_next_variable;
563-
tee_efivar_ops.set_variable = tee_set_variable;
564-
tee_efivar_ops.set_variable_nonblocking = tee_set_variable_nonblocking;
565-
tee_efivar_ops.query_variable_store = efi_query_variable_store;
566-
tee_efivar_ops.query_variable_info = tee_query_variable_info;
567-
568569
efivars_generic_ops_unregister();
569570
pr_info("Using TEE-based EFI runtime variable services\n");
570571
efivars_register(&tee_efivars, &tee_efivar_ops);

0 commit comments

Comments
 (0)