[U-Boot] [PATCH 2/2] efi_loader: simplify protocol installation

Heinrich Schuchardt xypron.glpk at gmx.de
Fri Apr 12 05:22:32 UTC 2019


By using InstallMultipleProtocolInterfaces() the coding for installing
protocol interfaces on the root node can be simplified.

Suggested-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 lib/efi_loader/efi_root_node.c | 76 +++++++++++-----------------------
 1 file changed, 25 insertions(+), 51 deletions(-)

diff --git a/lib/efi_loader/efi_root_node.c b/lib/efi_loader/efi_root_node.c
index b58d9d8c96..392f5c4951 100644
--- a/lib/efi_loader/efi_root_node.c
+++ b/lib/efi_loader/efi_root_node.c
@@ -26,16 +26,10 @@ struct efi_root_dp {
  */
 efi_status_t efi_root_node_register(void)
 {
-	efi_handle_t root;
-	efi_status_t ret;
+	efi_handle_t root = NULL;
 	struct efi_root_dp *dp;

-	/* Create handle */
-	ret = efi_create_handle(&root);
-	if (ret != EFI_SUCCESS)
-		return ret;
-
-	/* Install device path protocol */
+	/* Create device path protocol */
 	dp = calloc(1, sizeof(*dp));
 	if (!dp)
 		return EFI_OUT_OF_RESOURCES;
@@ -51,49 +45,29 @@ efi_status_t efi_root_node_register(void)
 	dp->end.sub_type = DEVICE_PATH_SUB_TYPE_END;
 	dp->end.length = sizeof(struct efi_device_path);

-	/* Install device path protocol */
-	ret = efi_add_protocol(root, &efi_guid_device_path, dp);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
-	/* Install device path to text protocol */
-	ret = efi_add_protocol(root, &efi_guid_device_path_to_text_protocol,
-			       (void *)&efi_device_path_to_text);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
-	/* Install device path utilities protocol */
-	ret = efi_add_protocol(root, &efi_guid_device_path_utilities_protocol,
-			       (void *)&efi_device_path_utilities);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
-	/* Install Unicode collation protocol */
-	ret = efi_add_protocol(root, &efi_guid_unicode_collation_protocol,
-			       (void *)&efi_unicode_collation_protocol);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
+	/* Create root node and install protocols */
+	return EFI_CALL(efi_install_multiple_protocol_interfaces(&root,
+		       /* Device path protocol */
+		       &efi_guid_device_path, dp,
+		       /* Device path to text protocol */
+		       &efi_guid_device_path_to_text_protocol,
+		       (void *)&efi_device_path_to_text,
+		       /* Device path utilities protocol */
+		       &efi_guid_device_path_utilities_protocol,
+		       (void *)&efi_device_path_utilities,
+		       /* Unicode collation protocol */
+		       &efi_guid_unicode_collation_protocol,
+		       (void *)&efi_unicode_collation_protocol,
 #if CONFIG_IS_ENABLED(EFI_LOADER_HII)
-	/* Install HII string protocol */
-	ret = efi_add_protocol(root, &efi_guid_hii_string_protocol,
-			       (void *)&efi_hii_string);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
-	/* Install HII database protocol */
-	ret = efi_add_protocol(root, &efi_guid_hii_database_protocol,
-			       (void *)&efi_hii_database);
-	if (ret != EFI_SUCCESS)
-		goto failure;
-
-	/* Install HII configuration routing protocol */
-	ret = efi_add_protocol(root, &efi_guid_hii_config_routing_protocol,
-			       (void *)&efi_hii_config_routing);
-	if (ret != EFI_SUCCESS)
-		goto failure;
+		       /* HII string protocol */
+		       &efi_guid_hii_string_protocol,
+		       (void *)&efi_hii_string,
+		       /* HII database protocol */
+		       &efi_guid_hii_database_protocol,
+		       (void *)&efi_hii_database,
+		       /* HII configuration routing protocol */
+		       &efi_guid_hii_config_routing_protocol,
+		       (void *)&efi_hii_config_routing,
 #endif
-
-failure:
-	return ret;
+		       NULL));
 }
--
2.20.1



More information about the U-Boot mailing list