From patchwork Mon Jul 5 08:49:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 470198 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3799446jao; Mon, 5 Jul 2021 01:49:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxSpmMyaH42cgv5qjKHkCTxbjOYMVFyrI+AwOlfb8ZAODiu8fKhfBToIykG8w7XcJiO8Pm X-Received: by 2002:aa7:cf91:: with SMTP id z17mr15029963edx.112.1625474972694; Mon, 05 Jul 2021 01:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625474972; cv=none; d=google.com; s=arc-20160816; b=teaTRw4yKccif8MTLz5+mhd20iPE0LjRbbLwF94xvmgHZSXb/07vr02HQky5niRKFO IICyTY/Bo8JWSWZnV90TjvdE91lP2gdbNeTs9DEZ5tNR9Mxr8U2p+YnH5d6METfQ3zaI byPbsUvZzgL14TF9MuaTiiFECwHVObwHoPceqCTzbUAGpb7gmLPbhfiPA2S6prvTLluX tC9cVlIiJSjukSiwQktGyRCjbvgbJaLXGug3AmuWRSunDEbo58gRd3e0lX5N09jaPPC3 NezNHarmd00Dv6rCmtsYVQGI6vaH0Yh+bG7QwO/LWehoe/QbfAafoMLM2niOymLhhlw/ 1Yag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=2NMlalI/DwrOJTl+H8IWiT7qYzMi0daDKf21Z4o2LqE=; b=yQvd1E62UOyL5fA6fBVOENGkq/gYN76VGu1o3VS1VKAN20T5gnvP+Rh++rlx0O+Cga NUXctNcEmcJ0PFEAK+wFCjZYK3hP3Pea6tuCN/bq6ggW1fgvhD2spzymYFCK1u1Tjzvi gokngDpGdRwnJ9YWneBZe65Uni8nEkb64iJagVPhDcWeT5Kx478S6qIOQpN0sIVPYqEA ++zB+zN8p/pEVDDLRxcSJ2l6xgEOT9luZzx7NpqvzLkuF6WNoVRNcj0LePs61anNigJb rCULZg6QY/ylAW3bxp5b494noiBq7bztqOi+XgDJbYZh7d/461Uikv5YIGaoLOQmHvey JX5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xNC8jzNc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id cw19si10309772ejc.372.2021.07.05.01.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 01:49:32 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xNC8jzNc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 294F3814A4; Mon, 5 Jul 2021 10:49:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xNC8jzNc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E867482A29; Mon, 5 Jul 2021 10:49:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5A64F80F47 for ; Mon, 5 Jul 2021 10:49:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32f.google.com with SMTP id t14-20020a05600c198eb029020c8aac53d4so1783633wmq.1 for ; Mon, 05 Jul 2021 01:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2NMlalI/DwrOJTl+H8IWiT7qYzMi0daDKf21Z4o2LqE=; b=xNC8jzNcLv9LY/jkBjaRike4vLLLn/GXw5l80eRooMO159Z5Aapuu09m0zM1ZPKYcw F8NU8zGcgmV5Ft0lgwQJsEO9UldhToyQelN8S/fOr3OvPMOOsgelVWMSMo91AFm8mPen U192kcYQp/Ssm3jj7/PZls1RZUOJLSJKFkVtzUJDXW2dtvf055Wg6skD3v6ffeUsL7gY T57P+uwTrPAedsv429HFqwO7Oi4oyulZ9/Bhlc1T5puPUs1yJ7joiA/F8/msS0ejLZ4x fdvWX7ebJUaU28L9Qg758KLCGi6Vv3vGXpAiopLH18/7WhaxTdAlrx5wWwAaHlhhaIMZ /W0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2NMlalI/DwrOJTl+H8IWiT7qYzMi0daDKf21Z4o2LqE=; b=K2kQu7Sbh8FBmu35dq++Dxw8UU2bqBpLRGpznlO1rLG/6SzsaWKhkyw+jXEBb3yFFn tpwzzWBJsQMO0688GFeFa4/3pNaZIOgECS/pMF30mEhBgzxuSLBDZAYXHkM1iE4zzocE SXCufHpoM5+RAbv94CK+3Z6HMxq+NLNdKbFr0xc/TzFRAqaQs8HsKDsRAmrdOFRdMXll FyQ8P5w8O2GinoNByqGt1tOYbYvv79SxhEF7tpl6t+fi3SGtMTKpks6NDuXSsHl4MI3Q DU4quBxot1Jb5sFLSpxNTzM3zXatnEfWDxXBwI4t7CNx1FWPq7FYpi/xEN+NFFjMPmUS ViYQ== X-Gm-Message-State: AOAM530r3730619ZCgg8/UWYEZUmGy5G09BUEtkmrc3jrfxTcmXEuVSG k7jb0RdClqL7qmyTSdjnA4fVgw== X-Received: by 2002:a05:600c:4143:: with SMTP id h3mr13695813wmm.35.1625474964744; Mon, 05 Jul 2021 01:49:24 -0700 (PDT) Received: from localhost.localdomain (ppp-94-66-242-227.home.otenet.gr. [94.66.242.227]) by smtp.gmail.com with ESMTPSA id o3sm12479461wrw.56.2021.07.05.01.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 01:49:24 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: da@libre.computer, Ilias Apalodimas , Simon Glass , Bin Meng , Christian Gmeiner , u-boot@lists.denx.de Subject: [PATCH] smbios: Try CONFIG_SYS_ options before using "Unknow" as a value Date: Mon, 5 Jul 2021 11:49:15 +0300 Message-Id: <20210705084915.32008-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.32.0.rc0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- lib/smbios.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.32.0.rc0 Reviewed-by: Bin Meng Reviewed-by: Simon Glass 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;