From patchwork Fri Nov 29 15:40:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 1202518 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sntech.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47Pdzf1TLLz9sPj for ; Sat, 30 Nov 2019 02:42:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E32ECC21C38; Fri, 29 Nov 2019 15:41:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1E7B3C21E2F; Fri, 29 Nov 2019 15:41:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 06D0BC21C2C; Fri, 29 Nov 2019 15:41:08 +0000 (UTC) Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lists.denx.de (Postfix) with ESMTPS id 82192C21C2F for ; Fri, 29 Nov 2019 15:41:05 +0000 (UTC) Received: from p5b127909.dip0.t-ipconnect.de ([91.18.121.9] helo=phil.sntech) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iaiOD-0000Gw-DX; Fri, 29 Nov 2019 16:41:01 +0100 From: Heiko Stuebner To: u-boot@lists.denx.de Date: Fri, 29 Nov 2019 16:40:43 +0100 Message-Id: <20191129154043.17395-2-heiko@sntech.de> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191129154043.17395-1-heiko@sntech.de> References: <20191129154043.17395-1-heiko@sntech.de> MIME-Version: 1.0 Cc: Heiko Stuebner , christoph.muellner@theobroma-systems.com Subject: [U-Boot] [PATCH 2/2] rockchip: misc: protect serial# from getting overwritten X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Heiko Stuebner serial# is one of the vendor properties and thus protected from being overwritten if already set. If env_set is called anyway this result in some nasty warnings, so check for presence before trying that. In the same direction check for the presence of cpuid# and compare it to the actual hardware and emit a warning if they don't match. Signed-off-by: Heiko Stuebner Reviewed-by: Kever Yang --- arch/arm/mach-rockchip/misc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c index d0fb3d07a7..545b98baad 100644 --- a/arch/arm/mach-rockchip/misc.c +++ b/arch/arm/mach-rockchip/misc.c @@ -91,6 +91,7 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length) char cpuid_str[cpuid_length * 2 + 1]; u64 serialno; char serialno_str[17]; + const char *oldid; int i; memset(cpuid_str, 0, sizeof(cpuid_str)); @@ -112,8 +113,16 @@ int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length) serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32; snprintf(serialno_str, sizeof(serialno_str), "%016llx", serialno); + oldid = env_get("cpuid#"); + if (oldid && strcmp(oldid, cpuid_str) != 0) + printf("cpuid: value %s present in env does not match hardware %s\n", + oldid, cpuid_str); + env_set("cpuid#", cpuid_str); - env_set("serial#", serialno_str); + + /* Only generate serial# when none is set yet */ + if (!env_get("serial#")) + env_set("serial#", serialno_str); return 0; }