From patchwork Thu Jan 11 14:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 761857 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2429841wrz; Thu, 11 Jan 2024 06:39:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcALwde0U9jNuFLmBoubVj49UtLfMrPMxbJnH1PX20gWZUm67SllVdq9Zxa9erxpAvgfaa X-Received: by 2002:adf:c784:0:b0:337:64eb:1c4 with SMTP id l4-20020adfc784000000b0033764eb01c4mr722162wrg.7.1704983984125; Thu, 11 Jan 2024 06:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983984; cv=none; d=google.com; s=arc-20160816; b=czEhPCguHGk7UkENDiyUC53HfTeh2ffhHszekoA8pJtN/E43xeHfH2C0MSAdOFKekF H7V1P3Ix92fcT57DEufMAuEi2tuZ6gWxhzKzYnvds7drABPRpWXvTjlPDefft7sfGXg9 JMOkACeAfUNSp3pDOnt5OwdV8tB9eiIByIVVldkaZ0f7jE625sBsoC1BzrtjsuDtQANa c0JmFs07ZVlV1wmaNAEi/Q6lEfxrGLBibBmliGbNOH5JUn8fv5D7xfdgrx10pDs8xVdK Sd0JVv4P5yPjyb6ucl1bc2T6EGbeKhIAmxfbaUNgRykNuzFzepLvKdMOfoDlHNBY1FIY 0HSg== 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=wVMMSLbnmuEPTte6BBeZUkwUzzU7PQi11ajtPdJh2LE=; fh=Qha6wJxWwFQVGcPpfhEfoHoQ7NCfPZrKBMSoDD8387w=; b=oGGUSQ39/kW6k1y6LujktXR7cnb45BITSIYiCfKAUYqMYHAlpz7RdXzIv9cDpsXmNw /OoPLPVy1JtOjtEVwhbd+FV2TsdxE3V8ZRoDPtuBjrcsjzgm3p59Cq4zD2f51Zm0/Otj KGP/R+TvuM4MOM5BY5vk4yfIOKgG9co+JAT2ES40bbIev3PLgeu8QxE9Nxn214kN9Da3 /zrreZze8vZC6Wf4dI5li23cUHXuVqLX6OfuBXU/gdj5jafYNA/xXBYgOnmg1lyhgW/F yyaSuuRP6eE+Y+nclvlnzHWyugy61wGQ31yi5KlI/ufm4h5Hk1Jzdb5yddukJyFk9D8M O8Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBxjp7Y1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id m10-20020a056000174a00b003365bf62dc0si671885wrf.262.2024.01.11.06.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:39:44 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBxjp7Y1; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 89D288753C; Thu, 11 Jan 2024 15:39:42 +0100 (CET) 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="gBxjp7Y1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 25AE1877FD; Thu, 11 Jan 2024 15:39:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 372638749F for ; Thu, 11 Jan 2024 15:39:40 +0100 (CET) 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-ej1-x629.google.com with SMTP id a640c23a62f3a-a28f66dc7ffso1165736366b.0 for ; Thu, 11 Jan 2024 06:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983979; x=1705588779; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wVMMSLbnmuEPTte6BBeZUkwUzzU7PQi11ajtPdJh2LE=; b=gBxjp7Y1QwWiB4nAWmc9ijtHpPwtBNvO467ikvPUuofQQVqWg5R75qeHhKcA136I4Y VL6zHaYUiatcyqHeAF20CyCdYYHT+Tn9r7TnDzmxU01JnJidKwsZj99cbMtZ7ve2Lk4g zuW/gAtiHo6eqZSB/t81ZK0gArfXqyJAunOz4t6+WJYk4QAPzvFT+nYCGL1qp+KKREtF U4YaqUxr1oB+QxJhxjV7dqUejRHjE+gqBYiQZmLy1iKJuP5TsCgBAVvyCt2MuSKb7Zws n5j3qPqEYrKf6+Dmdiv8QuXWZJ3v9u3JMx72kVKey/km8WmK3Gu1+6c033e0TM+19xtA ZDzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983979; x=1705588779; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wVMMSLbnmuEPTte6BBeZUkwUzzU7PQi11ajtPdJh2LE=; b=pjQjvoNsm/OHsnsVPk/xFjl1I4Ul53kGx7YY6kPANvPItSK80jRq8Idfm3a7tKZPHj zeMx147/nF2Nb+9OQGvhie/vi2im6b8xkjHJcfsIvFVDR9vV0O4CgmGPDv2YpGwtPQp6 sNLyhVhocEHKAmRqb9lBpb9osLZ0IRJk9Rb3GjV+xPJI39yGCrZ5WWkmjQdsAHKth8nK pwClZ6U0DdhGdU12qlOWp0OF3M1Zy0IVxlNMff7allyfGCdftoLpORPrZU1POzS291eB QMaZdoe+7u7wL/8vpFgPvMR3kut987JbXGH5xKPaHuaXHEY3EoV5zMpSIoYN+zQ2ibjS K9Fg== X-Gm-Message-State: AOJu0Ywn1fG14US80IthFtSb/4sePSVHLXoy4rSn5TrGky4zMXrScuf6 /00s2rFBfWIZtexWxY89Df53vorMU7j9pRI/yUGRAUR/3OU= X-Received: by 2002:a17:906:1d6:b0:a2b:a4c1:52ef with SMTP id 22-20020a17090601d600b00a2ba4c152efmr996056ejj.3.1704983979579; Thu, 11 Jan 2024 06:39:39 -0800 (PST) Received: from hades.. (ppp089210121239.access.hol.gr. [89.210.121.239]) by smtp.gmail.com with ESMTPSA id j25-20020a1709066dd900b00a26af4d96c6sm655062ejt.4.2024.01.11.06.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:39:39 -0800 (PST) From: Ilias Apalodimas To: u-boot@lists.denx.de, trini@konsulko.com Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Peter Robinson Subject: [PATCH 1/2] smbios: shorten sysinfo_str declarations and use Date: Thu, 11 Jan 2024 16:39:35 +0200 Message-Id: <20240111143936.983448-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean sysinfo_str is a bit too long and makes indentation weird. Shorten it to si_str. Signed-off-by: Ilias Apalodimas --- lib/smbios.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.37.2 diff --git a/lib/smbios.c b/lib/smbios.c index 41aa936c4c41..47db410a2141 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -48,20 +48,20 @@ DECLARE_GLOBAL_DATA_PTR; /** * struct map_sysinfo - Mapping of sysinfo strings to DT * - * @sysinfo_str: sysinfo string + * @si_str: sysinfo string * @dt_str: DT string * @max: Max index of the tokenized string to pick. Counting starts from 0 * */ struct map_sysinfo { - const char *sysinfo_str; + const char *si_str; const char *dt_str; int max; }; static const struct map_sysinfo sysinfo_to_dt[] = { - { .sysinfo_str = "product", .dt_str = "model", 2 }, - { .sysinfo_str = "manufacturer", .dt_str = "compatible", 1 }, + { .si_str = "product", .dt_str = "model", 2 }, + { .si_str = "manufacturer", .dt_str = "compatible", 1 }, }; /** @@ -108,12 +108,12 @@ struct smbios_write_method { const char *subnode_name; }; -static const struct map_sysinfo *convert_sysinfo_to_dt(const char *sysinfo_str) +static const struct map_sysinfo *convert_sysinfo_to_dt(const char *si) { int i; for (i = 0; i < ARRAY_SIZE(sysinfo_to_dt); i++) { - if (!strcmp(sysinfo_str, sysinfo_to_dt[i].sysinfo_str)) + if (!strcmp(si, sysinfo_to_dt[i].si_str)) return &sysinfo_to_dt[i]; } From patchwork Thu Jan 11 14:39:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 761858 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2429895wrz; Thu, 11 Jan 2024 06:39:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFW3iSzaOU+qq2yZbyG3Y9R2+5JleH6jeDh2xzQu1h/Pc3r5cvHCiu52cuWpYFtWsEFMyT9 X-Received: by 2002:a05:600c:4ed3:b0:40e:5f61:56a7 with SMTP id g19-20020a05600c4ed300b0040e5f6156a7mr254805wmq.323.1704983993757; Thu, 11 Jan 2024 06:39:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704983993; cv=none; d=google.com; s=arc-20160816; b=jjDxcJGHmbm1wtHxkQVgkRh2YCf7aQlXzF3JhFE2bAvVTQi41cxi5Tz8JJeQg2q+dt s0DDsR6jLPx68POd0gxnqCZr3kirvXHW3kAEp4wRyOsLYOs8fP5MF0VGUiEjbSsSSZns tuerbm+Dq8nb4Fn7ITK1amKUhi0m8+K4P2Rfg//R716oI3HOU47t6iLCCty3WqOpbmPl msxQgF+VGvPAsoQabJ6TFOMz6tsqfptmog8Ny6KPGO+s3f9P+PvkMGWbQPeyXf7GL/T7 EU2Bd7iz8UeV9DIVRI/HppT6yPQ/gR0INptBcOuxZc6BYaxVON9xp9Lmk+aPC9oTPnoy nYqQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TzTzR5VNiT0R5wEPYpe09GvA11cdNr11PvYP0OyMppI=; fh=Qha6wJxWwFQVGcPpfhEfoHoQ7NCfPZrKBMSoDD8387w=; b=SN2UJ1iyLAmwsGqNyFCtHbiiAz9/D+Fv+vp2snTjtWahi+KHcxsR8SRYiscS0MN4Ps 9L7xNxR20b2JjII8gATk2MpyT0CQ7MAzMo+GIWQuBCOBayUkAga12iga/WMo2nB16vFR y7My2UHvwFUqNEmhlJHwYkUoGWF2moCwoQZUoCkzbq3Lno8+ih4AMUToQonQ3l3IA0xj eTkrV94EuedWlhyLw5Bx2oz4imMTRKsczgdZTiZSgibOc+x49fCg0X8hnFwLyjVKRFYw +6hjk5ySMvu8xvgtFn/AyoUyEAlperkGc0EelTM1eyX8oqJGNJqd5FW7oq+Tcrjdx5BV n+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKlmVlha; 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 z9-20020a05600c114900b0040e45515f67si692913wmz.221.2024.01.11.06.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:39:53 -0800 (PST) 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=bKlmVlha; 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 18941877C8; Thu, 11 Jan 2024 15:39:45 +0100 (CET) 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="bKlmVlha"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D69F87885; Thu, 11 Jan 2024 15:39:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 C0E458765B for ; Thu, 11 Jan 2024 15:39:41 +0100 (CET) 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-x32a.google.com with SMTP id 5b1f17b1804b1-40e5f615a32so6616945e9.1 for ; Thu, 11 Jan 2024 06:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704983981; x=1705588781; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TzTzR5VNiT0R5wEPYpe09GvA11cdNr11PvYP0OyMppI=; b=bKlmVlhaG/RTMuRbxSY/Gmu41zYMmVadbtXTrRWDh137EAp5ZgoVPGiCdCYYCmChOC FpWspjBOnFIxUD3Fp5K3DVcWtZitY3ZSfZB3wg5o3LraFKc1TUUokuUy7r6bOGs2mGjs 74Cogu07g5YcuBy9SIfvqRqP6ZbOQ96LAc395NwzSqIzmjOcyZ8QaWYfoFEK2PGr/vK+ taPs+6Ixai2IaRc1YsEvE6aF83X/TxFSwHhGJT/YM3r8gbyBY5eEvlrd+ulBvIRrZfCQ XjRfr7cE6itAvckibl+S6mePh/BxlbmrioxYcYkS30ATCD+J5tnUzrEqeSm31AJJp7+S h9jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704983981; x=1705588781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TzTzR5VNiT0R5wEPYpe09GvA11cdNr11PvYP0OyMppI=; b=cwjGi3yTYfAEmn5bg/6v8YEPM35S1s5bjINNCRHFV16sctlsxBRdDnqw4tybg93kx0 j6FE+QE73sFaDYo/TzGBO0tmWUayV1oCFcFsN2cd/ZAZPbR/oqRXeNhu8aAUt2l9cgwN mgmpPFD17ZLLOZVCXx4N0O8IZrwn/irAlAFdu+DJvPtjOF7NpP1ZVTrYQm4SH7hwy2G4 l2Ecq3z4tQ5sfmiW6gOiu4yL7QIigQMl0c3sWUheMJAeWoEy58cYxh4ajGAdIUiS4PnA wrx1zmL65JZ0fObYh9jbJRHaH50TuP1jlem4jrVd9ykwNbZzOqqfjyqK34owxTGmGq9L bT2g== X-Gm-Message-State: AOJu0Yx3UK2bIlPxJMyCXjuqpLSGej0x2nWRtG2xbg+2BzVTu4mU/go/ oNGimLrUOOlvMAlN1vs1NKzGJIfh+XwW0LOCL8y4ttUa/Pg= X-Received: by 2002:a05:600c:4e14:b0:40e:567f:38d7 with SMTP id b20-20020a05600c4e1400b0040e567f38d7mr265434wmq.225.1704983981314; Thu, 11 Jan 2024 06:39:41 -0800 (PST) Received: from hades.. (ppp089210121239.access.hol.gr. [89.210.121.239]) by smtp.gmail.com with ESMTPSA id j25-20020a1709066dd900b00a26af4d96c6sm655062ejt.4.2024.01.11.06.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:39:41 -0800 (PST) From: Ilias Apalodimas To: u-boot@lists.denx.de, trini@konsulko.com Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Peter Robinson Subject: [PATCH 2/2] smbios: fix matching issues for table types Date: Thu, 11 Jan 2024 16:39:36 +0200 Message-Id: <20240111143936.983448-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20240111143936.983448-1-ilias.apalodimas@linaro.org> References: <20240111143936.983448-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean commit 738b34668f28 ("smbios: Fallback to the default DT if sysinfo nodes are missing") allowed the code to fallback and fill in SMBIOS tables with properties from the compatible and product nodes of the DT, in case the 'smbios,sysinfo' node is missing. That works fine for Type1/2 tables, but for other types we need to match the smbios,sysinfo subnode name as well. So add it to the smbios_ctx and check it during the sysinfo <-> DT mathcing Signed-off-by: Ilias Apalodimas --- We still lack selftests for smbios code. Heinrich started an effort here [0]. I'll update that once his series gets merged [0] https://lore.kernel.org/u-boot/20231223004429.247301-4-xypron.glpk@gmx.de/#t lib/smbios.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) -- 2.37.2 diff --git a/lib/smbios.c b/lib/smbios.c index 47db410a2141..64e65bfd6f93 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -54,32 +54,38 @@ DECLARE_GLOBAL_DATA_PTR; * */ struct map_sysinfo { + const char *si_node; const char *si_str; const char *dt_str; int max; }; static const struct map_sysinfo sysinfo_to_dt[] = { - { .si_str = "product", .dt_str = "model", 2 }, - { .si_str = "manufacturer", .dt_str = "compatible", 1 }, + { .si_node = "system", .si_str = "product", .dt_str = "model", 2 }, + { .si_node = "system", .si_str = "manufacturer", .dt_str = "compatible", 1 }, + { .si_node = "baseboard", .si_str = "product", .dt_str = "model", 2 }, + { .si_node = "baseboard", .si_str = "manufacturer", .dt_str = "compatible", 1 }, }; /** * struct smbios_ctx - context for writing SMBIOS tables * - * @node: node containing the information to write (ofnode_null() if none) - * @dev: sysinfo device to use (NULL if none) - * @eos: end-of-string pointer for the table being processed. This is set - * up when we start processing a table - * @next_ptr: pointer to the start of the next string to be added. When the - * table is nopt empty, this points to the byte after the \0 of the - * previous string. - * @last_str: points to the last string that was written to the table, or NULL - * if none + * @node: node containing the information to write (ofnode_null() + * if none) + * @dev: sysinfo device to use (NULL if none) + * @subnode_name: sysinfo subnode_name. Used for DT fallback + * @eos: end-of-string pointer for the table being processed. + * This is set up when we start processing a table + * @next_ptr: pointer to the start of the next string to be added. + * When the table is not empty, this points to the byte + * after the \0 of the previous string. + * @last_str: points to the last string that was written to the table, + * or NULL if none */ struct smbios_ctx { ofnode node; struct udevice *dev; + const char *subnode_name; char *eos; char *next_ptr; char *last_str; @@ -108,12 +114,13 @@ struct smbios_write_method { const char *subnode_name; }; -static const struct map_sysinfo *convert_sysinfo_to_dt(const char *si) +static const struct map_sysinfo *convert_sysinfo_to_dt(const char *node, const char *si) { int i; for (i = 0; i < ARRAY_SIZE(sysinfo_to_dt); i++) { - if (!strcmp(si, sysinfo_to_dt[i].si_str)) + if (node && !strcmp(node, sysinfo_to_dt[i].si_node) && + !strcmp(si, sysinfo_to_dt[i].si_str)) return &sysinfo_to_dt[i]; } @@ -233,7 +240,7 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, } else { const struct map_sysinfo *nprop; - nprop = convert_sysinfo_to_dt(prop); + nprop = convert_sysinfo_to_dt(ctx->subnode_name, prop); get_str_from_dt(nprop, str_dt, sizeof(str_dt)); str = (const char *)str_dt; } @@ -574,9 +581,13 @@ ulong write_smbios_table(ulong addr) int tmp; method = &smbios_write_funcs[i]; - if (IS_ENABLED(CONFIG_OF_CONTROL) && method->subnode_name) - ctx.node = ofnode_find_subnode(parent_node, - method->subnode_name); + ctx.subnode_name = NULL; + if (method->subnode_name) { + ctx.subnode_name = method->subnode_name; + if (IS_ENABLED(CONFIG_OF_CONTROL)) + ctx.node = ofnode_find_subnode(parent_node, + method->subnode_name); + } tmp = method->write((ulong *)&addr, handle++, &ctx); max_struct_size = max(max_struct_size, tmp);