[U-Boot] [PATCH 01/16] efi: Update efi_smbios_register() to return error code

Simon Glass sjg at chromium.org
Sun Sep 17 22:59:12 UTC 2017


This function can fail but gives no indication of failure. Update it to
return an error when something goes wrong.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 include/efi_loader.h        | 10 ++++++++--
 lib/efi_loader/efi_smbios.c |  6 ++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 2051fc994e..79d2dad22c 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -150,8 +150,14 @@ int efi_disk_register(void);
 int efi_gop_register(void);
 /* Called by bootefi to make the network interface available */
 int efi_net_register(void **handle);
-/* Called by bootefi to make SMBIOS tables available */
-void efi_smbios_register(void);
+/**
+ * efi_smbios_register() - write out SMBIOS tables
+ *
+ * Called by bootefi to make SMBIOS tables available
+ *
+ * @return 0 if OK, -ENOMEM if no memory is available for the tables
+ */
+int efi_smbios_register(void);
 
 /* Called by networking code to memorize the dhcp ack package */
 void efi_net_set_dhcp_ack(void *pkt, int len);
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index ac412e7362..3b87294dc3 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -13,7 +13,7 @@
 
 static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
 
-void efi_smbios_register(void)
+int efi_smbios_register(void)
 {
 	/* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
 	uint64_t dmi = 0xffffffff;
@@ -22,11 +22,13 @@ void efi_smbios_register(void)
 	int memtype = EFI_RUNTIME_SERVICES_DATA;
 
 	if (efi_allocate_pages(1, memtype, pages, &dmi) != EFI_SUCCESS)
-		return;
+		return -ENOMEM;
 
 	/* Generate SMBIOS tables */
 	write_smbios_table(dmi);
 
 	/* And expose them to our EFI payload */
 	efi_install_configuration_table(&smbios_guid, (void*)(uintptr_t)dmi);
+
+	return 0;
 }
-- 
2.14.1.690.gbb1197296e-goog



More information about the U-Boot mailing list