All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] smbios: Simplify reporting of unknown values
@ 2022-09-06 13:44 Ilias Apalodimas
  2022-09-06 13:44 ` [PATCH 2/2] smbios: Fallback to the default DT if sysinfo nodes are missing Ilias Apalodimas
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ilias Apalodimas @ 2022-09-06 13:44 UTC (permalink / raw)
  To: u-boot; +Cc: trini, sjg, heinrich.schuchardt, pbrobinson, Ilias Apalodimas

If a value is not valid during the DT or SYSINFO parsing,  we explicitly
set that to "Unknown Product" and "Unknown" for the product and
manufacturer respectively.  It's cleaner if we move the checks insisde
smbios_add_string() and always report "Unknown" regardless of the missing
field.

pre-patch dmidecode
<snip>
Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: Unknown
        Product Name: Unknown Product
        Version: Not Specified
        Serial Number: Not Specified
        UUID: Not Settable
        Wake-up Type: Reserved
        SKU Number: Not Specified
        Family: Not Specified

Handle 0x0002, DMI type 2, 14 bytes
Base Board Information
        Manufacturer: Unknown
        Product Name: Unknown Product
        Version: Not Specified
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Features:
                Board is a hosting board
        Location In Chassis: Not Specified
        Chassis Handle: 0x0000
        Type: Motherboard
<snip>

post-patch dmidecode:

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: Unknown
        Product Name: Unknown
        Version: Unknown
        Serial Number: Unknown
        UUID: Not Settable
        Wake-up Type: Reserved
        SKU Number: Unknown
        Family: Unknown

Handle 0x0002, DMI type 2, 14 bytes
Base Board Information
        Manufacturer: Unknown
        Product Name: Unknown
        Version: Unknown
        Serial Number: Not Specified
        Asset Tag: Unknown
        Features:
                Board is a hosting board
        Location In Chassis: Not Specified
        Chassis Handle: 0x0000
        Type: Motherboard

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/smbios.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/lib/smbios.c b/lib/smbios.c
index d7f4999e8b2a..fcc8686993ef 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -102,7 +102,7 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str)
 	int i = 1;
 	char *p = ctx->eos;
 
-	if (!*str)
+	if (!str || !*str)
 		str = "Unknown";
 
 	for (;;) {
@@ -151,8 +151,7 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop,
 		const char *str;
 
 		str = ofnode_read_string(ctx->node, prop);
-		if (str)
-			return smbios_add_string(ctx, str);
+		return smbios_add_string(ctx, str);
 	}
 
 	return 0;
@@ -231,7 +230,7 @@ static int smbios_write_type0(ulong *current, int handle,
 	t->vendor = smbios_add_string(ctx, "U-Boot");
 
 	t->bios_ver = smbios_add_prop(ctx, "version");
-	if (!t->bios_ver)
+	if (!strcmp(ctx->last_str, "Unknown"))
 		t->bios_ver = smbios_add_string(ctx, PLAIN_VERSION);
 	if (t->bios_ver)
 		gd->smbios_version = ctx->last_str;
@@ -281,11 +280,7 @@ static int smbios_write_type1(ulong *current, int handle,
 	fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, 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->product_name = smbios_add_prop(ctx, "product");
-	if (!t->product_name)
-		t->product_name = smbios_add_string(ctx, "Unknown Product");
 	t->version = smbios_add_prop_si(ctx, "version",
 					SYSINFO_ID_SMBIOS_SYSTEM_VERSION);
 	if (serial_str) {
@@ -315,11 +310,7 @@ static int smbios_write_type2(ulong *current, int handle,
 	fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, 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->product_name = smbios_add_prop(ctx, "product");
-	if (!t->product_name)
-		t->product_name = smbios_add_string(ctx, "Unknown Product");
 	t->version = smbios_add_prop_si(ctx, "version",
 					SYSINFO_ID_SMBIOS_BASEBOARD_VERSION);
 	t->asset_tag_number = smbios_add_prop(ctx, "asset-tag");
@@ -344,8 +335,6 @@ static int smbios_write_type3(ulong *current, int handle,
 	fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, 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->chassis_type = SMBIOS_ENCLOSURE_DESKTOP;
 	t->bootup_state = SMBIOS_STATE_SAFE;
 	t->power_supply_state = SMBIOS_STATE_SAFE;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-09-30 14:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 13:44 [PATCH 1/2] smbios: Simplify reporting of unknown values Ilias Apalodimas
2022-09-06 13:44 ` [PATCH 2/2] smbios: Fallback to the default DT if sysinfo nodes are missing Ilias Apalodimas
2022-09-20 11:10   ` Peter Robinson
2022-09-29  9:59     ` Simon Glass
2022-09-29 10:23       ` Ilias Apalodimas
2022-09-29 23:55         ` Simon Glass
2022-09-30  9:56           ` Mark Kettenis
2022-09-30 14:51             ` Tom Rini
2022-09-12 18:31 ` [PATCH 1/2] smbios: Simplify reporting of unknown values Simon Glass
2022-09-16 20:30   ` Ilias Apalodimas
2022-09-17 16:55     ` Sean Anderson
2022-09-26 10:56       ` Ilias Apalodimas
2022-09-29  4:34         ` Sean Anderson
2022-09-29  9:59           ` Simon Glass
2022-09-29 14:02             ` Sean Anderson
2022-09-30 14:25               ` Tom Rini
2022-09-29 10:09           ` Ilias Apalodimas
2022-09-20 10:15   ` Peter Robinson
2022-09-20 11:09 ` Peter Robinson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.