diff --git a/target/linux/generic/pending-6.18/805-03-nvmem-u-boot-env-post-process-ethaddr-numbered.patch b/target/linux/generic/pending-6.18/805-03-nvmem-u-boot-env-post-process-ethaddr-numbered.patch new file mode 100644 index 00000000000..1169c6400c1 --- /dev/null +++ b/target/linux/generic/pending-6.18/805-03-nvmem-u-boot-env-post-process-ethaddr-numbered.patch @@ -0,0 +1,46 @@ +From: "Michael C. Pratt" +Date: Wed Sep 9 00:21:51 2026 -0400 +Subject: [PATCH] generic: nvmem: u-boot-env: process numbered ethaddr variables + +Variable names with the pattern eth[0-9]addr is documented by u-boot +in a README file doc/README.enetaddr as being the preferred way +to store MAC addresses in the environment variables, +so process them as a binary address automatically. + +Suggested-by: Tomasz Maciej Nowak +Signed-off-by: "Michael C. Pratt" +--- + +--- a/drivers/nvmem/layouts/u-boot-env.c ++++ b/drivers/nvmem/layouts/u-boot-env.c +@@ -4,6 +4,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -91,6 +92,22 @@ static int u_boot_env_parse_cells(struct + } + } + ++ /* Process eth[0-9]addr variables as a MAC address. */ ++ if (!strncmp(var, "eth", 3) && isdigit(var[3]) && !strncmp(var + 4, "addr", 4) && ++ strlen(var) == 8 && info.bytes == MAC_ADDR_STR_LEN) { ++ info.raw_len = strlen(value); ++ info.bytes = ETH_ALEN; ++ info.read_post_process = u_boot_env_read_post_process_ethaddr; ++ } ++ /* Handle quotation which increases length by 2 and offset by 1 if present. */ ++ if (!strncmp(var, "eth", 3) && isdigit(var[3]) && !strncmp(var + 4, "addr", 4) && ++ strlen(var) == 8 && info.bytes == MAC_ADDR_STR_LEN + 2) { ++ info.offset = data_offset + value - data + 1; ++ info.raw_len = strlen(value); ++ info.bytes = ETH_ALEN; ++ info.read_post_process = u_boot_env_read_post_process_ethaddr; ++ } ++ + nvmem_add_one_cell(nvmem, &info); + } +