]> Git Repo - J-u-boot.git/blobdiff - lib/efi_selftest/efi_selftest_exitbootservices.c
ARM: dts: at91: sama7g5: add assigned clocks for sdmmc1
[J-u-boot.git] / lib / efi_selftest / efi_selftest_exitbootservices.c
index 60271e618089e2fb95495e1cd39ef76cb25c2a6d..4fecd1b41519830bef31fc466344f91bb244d092 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
- * efi_selftest_events
+ * efi_selftest_exitbootservices
  *
  * Copyright (c) 2017 Heinrich Schuchardt <[email protected]>
  *
- * SPDX-License-Identifier:     GPL-2.0+
- *
  * This unit test checks that the notification function of an
  * EVT_SIGNAL_EXIT_BOOT_SERVICES event is called exactly once.
  */
 
 static struct efi_boot_services *boottime;
 static struct efi_event *event_notify;
-static unsigned int counter;
+static unsigned int notification_count;
 
 /*
- * Notification function, increments a counter.
+ * Notification function, increments the notification count.
  *
  * @event      notified event
- * @context    pointer to the counter
+ * @context    pointer to the notification count
  */
 static void EFIAPI notify(struct efi_event *event, void *context)
 {
-       if (!context)
-               return;
-       ++*(unsigned int *)context;
+       unsigned int *count = context;
+
+       ++*count;
 }
 
 /*
@@ -35,6 +34,7 @@ static void EFIAPI notify(struct efi_event *event, void *context)
  *
  * @handle:    handle of the loaded image
  * @systable:  system table
+ * @return:    EFI_ST_SUCCESS for success
  */
 static int setup(const efi_handle_t handle,
                 const struct efi_system_table *systable)
@@ -43,35 +43,16 @@ static int setup(const efi_handle_t handle,
 
        boottime = systable->boottime;
 
-       counter = 0;
+       notification_count = 0;
        ret = boottime->create_event(EVT_SIGNAL_EXIT_BOOT_SERVICES,
-                                    TPL_CALLBACK, notify, (void *)&counter,
+                                    TPL_CALLBACK, notify,
+                                    (void *)&notification_count,
                                     &event_notify);
        if (ret != EFI_SUCCESS) {
                efi_st_error("could not create event\n");
-               return 1;
-       }
-       return 0;
-}
-
-/*
- * Tear down unit test.
- *
- * Close the event created in setup.
- */
-static int teardown(void)
-{
-       efi_status_t ret;
-
-       if (event_notify) {
-               ret = boottime->close_event(event_notify);
-               event_notify = NULL;
-               if (ret != EFI_SUCCESS) {
-                       efi_st_error("could not close event\n");
-                       return 1;
-               }
+               return EFI_ST_FAILURE;
        }
-       return 0;
+       return EFI_ST_SUCCESS;
 }
 
 /*
@@ -82,19 +63,21 @@ static int teardown(void)
  *
  * Call ExitBootServices again and check that the notification function is
  * not called again.
+ *
+ * @return:    EFI_ST_SUCCESS for success
  */
 static int execute(void)
 {
-       if (counter != 1) {
-               efi_st_error("ExitBootServices was not notified");
-               return 1;
+       if (notification_count != 1) {
+               efi_st_error("ExitBootServices was not notified\n");
+               return EFI_ST_FAILURE;
        }
        efi_st_exit_boot_services();
-       if (counter != 1) {
-               efi_st_error("ExitBootServices was notified twice");
-               return 1;
+       if (notification_count != 1) {
+               efi_st_error("ExitBootServices was notified twice\n");
+               return EFI_ST_FAILURE;
        }
-       return 0;
+       return EFI_ST_SUCCESS;
 }
 
 EFI_UNIT_TEST(exitbootservices) = {
@@ -102,5 +85,4 @@ EFI_UNIT_TEST(exitbootservices) = {
        .phase = EFI_SETUP_BEFORE_BOOTTIME_EXIT,
        .setup = setup,
        .execute = execute,
-       .teardown = teardown,
 };
This page took 0.029821 seconds and 4 git commands to generate.