diff options
author | Heiko Stuebner <heiko.stuebner@theobroma-systems.com> | 2019-11-29 18:40:43 +0300 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2019-12-05 18:53:07 +0300 |
commit | fd3a7ae8e6fa58a566dae182098effc61c2d9efd (patch) | |
tree | 0587ae79de4cc364d266a0c271b1dcf605403eb8 /arch/arm/mach-rockchip/misc.c | |
parent | d490fadc703c54f61e6ba8f47dfd7a4702ac2293 (diff) | |
download | u-boot-fd3a7ae8e6fa58a566dae182098effc61c2d9efd.tar.xz |
rockchip: misc: protect serial# from getting overwritten
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 <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'arch/arm/mach-rockchip/misc.c')
-rw-r--r-- | arch/arm/mach-rockchip/misc.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c index 546377e61d..6dbb9bde48 100644 --- a/arch/arm/mach-rockchip/misc.c +++ b/arch/arm/mach-rockchip/misc.c @@ -92,6 +92,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)); @@ -113,8 +114,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; } |