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

Simon Glass sjg at chromium.org
Mon Dec 4 21:28:17 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>
---

Changes in v2:
- Update return type of efi_smbios_register() to efi_status_t
- Use return value of efi_install_configuration_table

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

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 1b92edbd77..35f8f84401 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -164,7 +164,14 @@ int efi_gop_register(void);
 /* Called by bootefi to make the network interface available */
 int efi_net_register(void);
 /* 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
+ */
+efi_status_t efi_smbios_register(void);
 
 struct efi_simple_file_system_protocol *
 efi_fs_from_path(struct efi_device_path *fp);
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index ac412e7362..67f71892ca 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)
+efi_status_t efi_smbios_register(void)
 {
 	/* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
 	uint64_t dmi = 0xffffffff;
@@ -22,11 +22,12 @@ void efi_smbios_register(void)
 	int memtype = EFI_RUNTIME_SERVICES_DATA;
 
 	if (efi_allocate_pages(1, memtype, pages, &dmi) != EFI_SUCCESS)
-		return;
+		return EFI_OUT_OF_RESOURCES;
 
 	/* 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 efi_install_configuration_table(&smbios_guid,
+					       (void *)(uintptr_t)dmi);
 }
-- 
2.15.0.531.g2ccb3012c9-goog



More information about the U-Boot mailing list