]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
efi_selftest: simplify efi_st_query_variable_common
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 14 Nov 2025 09:32:44 +0000 (10:32 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 21 Nov 2025 18:30:32 +0000 (19:30 +0100)
Use global st_runtime.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
include/efi_selftest.h
lib/efi_selftest/efi_selftest_variables.c
lib/efi_selftest/efi_selftest_variables_common.c
lib/efi_selftest/efi_selftest_variables_runtime.c

index 4ee46cbbb66cb16aea6aa2d40d818fc2674a45be..874f8b5efe7b461af8fc332efd5193874830b884 100644 (file)
@@ -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
index 3d5f38c689784f79a7d99f0b8881750525c20a08..b92c3276b61981615bb3b12122e51c4f6721b1eb 100644 (file)
@@ -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;
index 453bc8709a6faf69ee70884dfea71da563a9dadb..704da016c6d6984435beeace65964fc44c6ec5cd 100644 (file)
 
 #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;
index 379c4f9c47b73d58022c344330535fcd855e5193..4be37efc1fc7c0f910c94b14d86ed4607b723975 100644 (file)
@@ -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;