[PATCH V6 4/4] board: dhelectronics: Sync env variable dh_som_serial_number with SN
Christoph Niedermaier
cniedermaier at dh-electronics.com
Sat Dec 7 00:04:20 CET 2024
The env variable "SN" is used to store the serial number on DH electronics
SoMs. New SoMs will use the variable "dh_som_serial_number". To ensure
compatibility, these env variables are synchronized. This is achieved
using callback functions.
Signed-off-by: Christoph Niedermaier <cniedermaier at dh-electronics.com>
Reviewed-by: Marek Vasut <marex at denx.de>
---
Cc: "NXP i.MX U-Boot Team" <uboot-imx at nxp.com>
Cc: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <festevam at gmail.com>
Cc: Stefano Babic <sbabic at denx.de>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at dh-electronics.com
---
V3: - Add this patch to the series
V4: - Remove the recursion prevention from the callback functions
=> The recursion prevention will be generally solved in the
callback function call in a separate patch
v5: - No functional changes, but changed the order of the patches
V6: - Add Reviewed-by tag
---
board/dhelectronics/common/dh_common.c | 17 +++++++++++++++++
configs/dhsom.config | 1 +
2 files changed, 18 insertions(+)
diff --git a/board/dhelectronics/common/dh_common.c b/board/dhelectronics/common/dh_common.c
index 6a942909cc..71010803f5 100644
--- a/board/dhelectronics/common/dh_common.c
+++ b/board/dhelectronics/common/dh_common.c
@@ -11,6 +11,23 @@
#include "dh_common.h"
+static int on_dh_som_serial_number(const char *name, const char *value, enum env_op op,
+ int flags)
+{
+ env_set("SN", value);
+ return 0;
+}
+
+U_BOOT_ENV_CALLBACK(dh_som_serial_number, on_dh_som_serial_number);
+
+static int on_SN(const char *name, const char *value, enum env_op op, int flags)
+{
+ env_set("dh_som_serial_number", value);
+ return 0;
+}
+
+U_BOOT_ENV_CALLBACK(SN, on_SN);
+
bool dh_mac_is_in_env(const char *env)
{
unsigned char enetaddr[6];
diff --git a/configs/dhsom.config b/configs/dhsom.config
index fc76632630..380bedaa5d 100644
--- a/configs/dhsom.config
+++ b/configs/dhsom.config
@@ -49,6 +49,7 @@ CONFIG_CMD_UUID=y
CONFIG_CMD_WGET=y
CONFIG_CMD_XXD=y
CONFIG_CRC32_VERIFY=y
+CONFIG_ENV_CALLBACK_LIST_STATIC="dh_som_serial_number:dh_som_serial_number,SN:SN,"
CONFIG_HASH_VERIFY=y
CONFIG_MD5SUM_VERIFY=y
CONFIG_SHA1SUM_VERIFY=y
--
2.30.2
More information about the U-Boot
mailing list