SMBIOS entries for manufacturer and board can't be empty, as the spec
explicitly requires a value.
Instead of passing "Unknown" and "Unknown product" for the manufacturer and
product name if the .dts options are missing, try to use CONFIG_SYS_VENDOR
and CONFIG_SYS_BOARD respectively.  If those are not found either warn the
user at runtime and use "Unknown" for both entries.

Signed-off-by: Ilias Apalodimas <[email protected]>
---
 lib/smbios.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index b52e125eeb14..d1997ce70d19 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -79,8 +79,10 @@ static int smbios_add_string(struct smbios_ctx *ctx, const 
char *str)
        int i = 1;
        char *p = ctx->eos;
 
-       if (!*str)
+       if (!*str) {
                str = "Unknown";
+               log_warning("Empty string found. Please fix your DTS and/or 
CONFIG_SYS_* options");
+       }
 
        for (;;) {
                if (!*p) {
@@ -259,10 +261,10 @@ static int smbios_write_type1(ulong *current, int handle,
        smbios_set_eos(ctx, t->eos);
        t->manufacturer = smbios_add_prop(ctx, "manufacturer");
        if (!t->manufacturer)
-               t->manufacturer = smbios_add_string(ctx, "Unknown");
+               t->manufacturer = smbios_add_string(ctx, CONFIG_SYS_VENDOR);
        t->product_name = smbios_add_prop(ctx, "product");
        if (!t->product_name)
-               t->product_name = smbios_add_string(ctx, "Unknown Product");
+               t->product_name = smbios_add_string(ctx, CONFIG_SYS_BOARD);
        t->version = smbios_add_prop_si(ctx, "version",
                                        SYSINFO_ID_SMBIOS_SYSTEM_VERSION);
        if (serial_str) {
@@ -293,10 +295,10 @@ static int smbios_write_type2(ulong *current, int handle,
        smbios_set_eos(ctx, t->eos);
        t->manufacturer = smbios_add_prop(ctx, "manufacturer");
        if (!t->manufacturer)
-               t->manufacturer = smbios_add_string(ctx, "Unknown");
+               t->manufacturer = smbios_add_string(ctx, CONFIG_SYS_VENDOR);
        t->product_name = smbios_add_prop(ctx, "product");
        if (!t->product_name)
-               t->product_name = smbios_add_string(ctx, "Unknown Product");
+               t->product_name = smbios_add_string(ctx, CONFIG_SYS_BOARD);
        t->version = smbios_add_prop_si(ctx, "version",
                                        SYSINFO_ID_SMBIOS_BASEBOARD_VERSION);
        t->asset_tag_number = smbios_add_prop(ctx, "asset-tag");
@@ -322,7 +324,7 @@ static int smbios_write_type3(ulong *current, int handle,
        smbios_set_eos(ctx, t->eos);
        t->manufacturer = smbios_add_prop(ctx, "manufacturer");
        if (!t->manufacturer)
-               t->manufacturer = smbios_add_string(ctx, "Unknown");
+               t->manufacturer = smbios_add_string(ctx, CONFIG_SYS_VENDOR);
        t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP;
        t->bootup_state = SMBIOS_STATE_SAFE;
        t->power_supply_state = SMBIOS_STATE_SAFE;
-- 
2.32.0.rc0

Reply via email to