[PATCH 5/7] efi_selftest: simplify efi_st_query_variable_common
Ilias Apalodimas
ilias.apalodimas at linaro.org
Tue Dec 2 13:43:44 CET 2025
On Fri, 14 Nov 2025 at 11:33, Heinrich Schuchardt
<heinrich.schuchardt at canonical.com> wrote:
>
> Use global st_runtime.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
> include/efi_selftest.h | 4 +-
> lib/efi_selftest/efi_selftest_variables.c | 3 +-
> .../efi_selftest_variables_common.c | 55 ++++++++-----------
> .../efi_selftest_variables_runtime.c | 4 +-
> 4 files changed, 28 insertions(+), 38 deletions(-)
>
> diff --git a/include/efi_selftest.h b/include/efi_selftest.h
> index 4ee46cbbb66..874f8b5efe7 100644
> --- a/include/efi_selftest.h
> +++ b/include/efi_selftest.h
> @@ -151,13 +151,11 @@ u16 efi_st_get_key(void);
> /**
> * efi_st_query_variable_common - Common variable tests for boottime/runtime
> *
> - * @runtime: Pointer to services table
> * @attributes: Attributes used
> *
> * Return: EFI_ST_SUCCESS/FAILURE
> */
> -int efi_st_query_variable_common(struct efi_runtime_services *runtime,
> - u32 attributes);
> +int efi_st_query_variable_common(u32 attributes);
>
> /**
> * struct efi_unit_test - EFI unit test
> diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c
> index 3d5f38c6897..b92c3276b61 100644
> --- a/lib/efi_selftest/efi_selftest_variables.c
> +++ b/lib/efi_selftest/efi_selftest_variables.c
> @@ -53,8 +53,7 @@ static int execute(void)
> efi_guid_t guid;
> int test_ret;
>
> - test_ret = efi_st_query_variable_common(runtime,
> - EFI_VARIABLE_BOOTSERVICE_ACCESS);
> + test_ret = efi_st_query_variable_common(EFI_VARIABLE_BOOTSERVICE_ACCESS);
> if (test_ret != EFI_ST_SUCCESS) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> diff --git a/lib/efi_selftest/efi_selftest_variables_common.c b/lib/efi_selftest/efi_selftest_variables_common.c
> index 453bc8709a6..704da016c6d 100644
> --- a/lib/efi_selftest/efi_selftest_variables_common.c
> +++ b/lib/efi_selftest/efi_selftest_variables_common.c
> @@ -11,15 +11,13 @@
>
> #define EFI_INVALID_ATTR BIT(30)
>
> -int efi_st_query_variable_common(struct efi_runtime_services *runtime,
> - u32 attributes)
> +int efi_st_query_variable_common(u32 attributes)
> {
> efi_status_t ret;
> u64 max_storage, rem_storage, max_size;
>
> - ret = runtime->query_variable_info(attributes,
> - &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(attributes, &max_storage,
> + &rem_storage, &max_size);
> if (ret != EFI_SUCCESS) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> @@ -28,58 +26,54 @@ int efi_st_query_variable_common(struct efi_runtime_services *runtime,
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(EFI_VARIABLE_RUNTIME_ACCESS,
> - &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(EFI_VARIABLE_RUNTIME_ACCESS,
> + &max_storage, &rem_storage,
> + &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(attributes,
> - NULL, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(attributes, NULL, &rem_storage,
> + &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(attributes,
> - &max_storage, NULL,
> - &max_size);
> + ret = st_runtime->query_variable_info(attributes, &max_storage, NULL,
> + &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(attributes,
> - &max_storage, &rem_storage,
> - NULL);
> + ret = st_runtime->query_variable_info(attributes, &max_storage,
> + &rem_storage, NULL);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(0, &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(0, &max_storage, &rem_storage,
> + &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(attributes |
> - EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
> - EFI_VARIABLE_NON_VOLATILE,
> - &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(
> + attributes | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
> + EFI_VARIABLE_NON_VOLATILE,
> + &max_storage, &rem_storage, &max_size);
> if (ret != EFI_UNSUPPORTED) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> }
>
> - ret = runtime->query_variable_info(EFI_VARIABLE_NON_VOLATILE,
> - &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(EFI_VARIABLE_NON_VOLATILE,
> + &max_storage, &rem_storage,
> + &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> @@ -89,10 +83,9 @@ int efi_st_query_variable_common(struct efi_runtime_services *runtime,
> * Use a mix existing/non-existing attribute bits from the
> * UEFI spec
> */
> - ret = runtime->query_variable_info(attributes | EFI_INVALID_ATTR |
> - EFI_VARIABLE_NON_VOLATILE,
> - &max_storage, &rem_storage,
> - &max_size);
> + ret = st_runtime->query_variable_info(
> + attributes | EFI_INVALID_ATTR | EFI_VARIABLE_NON_VOLATILE,
> + &max_storage, &rem_storage, &max_size);
> if (ret != EFI_INVALID_PARAMETER) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> diff --git a/lib/efi_selftest/efi_selftest_variables_runtime.c b/lib/efi_selftest/efi_selftest_variables_runtime.c
> index 379c4f9c47b..4be37efc1fc 100644
> --- a/lib/efi_selftest/efi_selftest_variables_runtime.c
> +++ b/lib/efi_selftest/efi_selftest_variables_runtime.c
> @@ -60,8 +60,8 @@ static int execute(void)
> memset(v2, 0x1, sizeof(v2));
>
> if (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) {
> - test_ret = efi_st_query_variable_common(runtime, EFI_VARIABLE_BOOTSERVICE_ACCESS |
> - EFI_VARIABLE_RUNTIME_ACCESS);
> + test_ret = efi_st_query_variable_common(EFI_VARIABLE_BOOTSERVICE_ACCESS |
> + EFI_VARIABLE_RUNTIME_ACCESS);
> if (test_ret != EFI_ST_SUCCESS) {
> efi_st_error("QueryVariableInfo failed\n");
> return EFI_ST_FAILURE;
> --
> 2.51.0
>
More information about the U-Boot
mailing list