From 512ed81e567e3dba05d92ce34e9fe2c4fb107373 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Mon, 10 Jun 2024 18:13:46 +0200 Subject: smbios: only look for a SYSINFO udevice if SYSINFO support is enabled If SYSINFO support isn't enabled, it's a given that uclass_first_device for UCLASS_SYSINFO will not find anything, therefore let's skip the test entirely. This allows to get rid of the following debug message that may be confusing: Cannot find uclass for id 118: please add the UCLASS_DRIVER() declaration for this UCLASS_... id Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- lib/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index b190b010f30..a822acd48e9 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -571,7 +571,7 @@ ulong write_smbios_table(ulong addr) int i; ctx.node = ofnode_null(); - if (IS_ENABLED(CONFIG_OF_CONTROL)) { + if (IS_ENABLED(CONFIG_OF_CONTROL) && CONFIG_IS_ENABLED(SYSINFO)) { uclass_first_device(UCLASS_SYSINFO, &ctx.dev); if (ctx.dev) parent_node = dev_read_subnode(ctx.dev, "smbios"); -- cgit v1.2.3 From 85df7f173cd2ec2acaf163e0136ef9e4e940917f Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 26 Apr 2024 15:38:12 +0200 Subject: lib: smbios: Let detect the system via sysinfo Currently code looks like that it sysinfo drivers are supported but actually none checking that system is detected. That's why call sysinfo_detect() to make sure that priv->detected in sysinfo uclass is setup hence information from driver can be passed to smbios. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- lib/smbios.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index a822acd48e9..c6c3b62ae64 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -573,8 +573,14 @@ ulong write_smbios_table(ulong addr) ctx.node = ofnode_null(); if (IS_ENABLED(CONFIG_OF_CONTROL) && CONFIG_IS_ENABLED(SYSINFO)) { uclass_first_device(UCLASS_SYSINFO, &ctx.dev); - if (ctx.dev) + if (ctx.dev) { + int ret; + parent_node = dev_read_subnode(ctx.dev, "smbios"); + ret = sysinfo_detect(ctx.dev); + if (ret) + return ret; + } } else { ctx.dev = NULL; } -- cgit v1.2.3 From a5a57562856e109654e793fc821a7fcb1a914d6e Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Fri, 26 Apr 2024 15:38:13 +0200 Subject: lib: smbios: Detect system properties via SYSINFO IDs Code is pretty much supports only DT properties and completely ignore information coming from sysinfo driver. Code is calling smbios_add_prop() which calls with smbios_add_prop_si(SYSINFO_ID_NONE). But SYSINFO_ID_NONE can't differentiate different entries from sysinfo driver. That's why introduce separate SYSINFO macros which can be used in sysinfo driver and passed to smbios structure. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- lib/smbios.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'lib/smbios.c') diff --git a/lib/smbios.c b/lib/smbios.c index c6c3b62ae64..fb6eaf1d5ca 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -383,8 +383,12 @@ static int smbios_write_type1(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type1)); fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer", NULL); - t->product_name = smbios_add_prop(ctx, "product", NULL); + t->manufacturer = smbios_add_prop_si(ctx, "manufacturer", + SYSINFO_ID_SMBIOS_SYSTEM_MANUFACTURER, + NULL); + t->product_name = smbios_add_prop_si(ctx, "product", + SYSINFO_ID_SMBIOS_SYSTEM_PRODUCT, + NULL); t->version = smbios_add_prop_si(ctx, "version", SYSINFO_ID_SMBIOS_SYSTEM_VERSION, NULL); @@ -392,11 +396,15 @@ static int smbios_write_type1(ulong *current, int handle, t->serial_number = smbios_add_prop(ctx, NULL, serial_str); strncpy((char *)t->uuid, serial_str, sizeof(t->uuid)); } else { - t->serial_number = smbios_add_prop(ctx, "serial", NULL); + t->serial_number = smbios_add_prop_si(ctx, "serial", + SYSINFO_ID_SMBIOS_SYSTEM_SERIAL, + NULL); } t->wakeup_type = SMBIOS_WAKEUP_TYPE_UNKNOWN; - t->sku_number = smbios_add_prop(ctx, "sku", NULL); - t->family = smbios_add_prop(ctx, "family", NULL); + t->sku_number = smbios_add_prop_si(ctx, "sku", + SYSINFO_ID_SMBIOS_SYSTEM_SKU, NULL); + t->family = smbios_add_prop_si(ctx, "family", + SYSINFO_ID_SMBIOS_SYSTEM_FAMILY, NULL); len = t->length + smbios_string_table_len(ctx); *current += len; @@ -415,12 +423,22 @@ static int smbios_write_type2(ulong *current, int handle, memset(t, 0, sizeof(struct smbios_type2)); fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); - t->manufacturer = smbios_add_prop(ctx, "manufacturer", NULL); - t->product_name = smbios_add_prop(ctx, "product", NULL); + t->manufacturer = smbios_add_prop_si(ctx, "manufacturer", + SYSINFO_ID_SMBIOS_BASEBOARD_MANUFACTURER, + NULL); + t->product_name = smbios_add_prop_si(ctx, "product", + SYSINFO_ID_SMBIOS_BASEBOARD_PRODUCT, + NULL); t->version = smbios_add_prop_si(ctx, "version", SYSINFO_ID_SMBIOS_BASEBOARD_VERSION, NULL); - t->asset_tag_number = smbios_add_prop(ctx, "asset-tag", NULL); + + t->serial_number = smbios_add_prop_si(ctx, "serial", + SYSINFO_ID_SMBIOS_BASEBOARD_SERIAL, + NULL); + t->asset_tag_number = smbios_add_prop_si(ctx, "asset-tag", + SYSINFO_ID_SMBIOS_BASEBOARD_ASSET_TAG, + NULL); t->feature_flags = SMBIOS_BOARD_FEATURE_HOSTING; t->board_type = SMBIOS_BOARD_MOTHERBOARD; t->chassis_handle = handle + 1; -- cgit v1.2.3