Ever since the transition from a separate NVMEM driver to the layout driver
in Linux commit 5f15811286af ("nvmem: layouts: add U-Boot env layout"),
it is very common within DTS to have the compatible string "u-boot,env"
in the nested nvmem-layout node instead of the parent partition node.This allows u-boot tools to detect the u-boot environment on a partition that is also using the layout driver for an NVMEM cell. Signed-off-by: Michael C. Pratt <[email protected]> --- tools/env/fw_env.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 49a068d91cc..8810b0e94dc 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -1737,7 +1737,14 @@ static int find_nvmem_device(void) fp = fopen(comp, "r"); if (!fp) { - continue; + bytes = snprintf(comp, sizeof(comp), "%s/%s/of_node/nvmem-layout/compatible", + path, dent->d_name); + if (bytes < 0 || bytes == sizeof(comp)) + continue; + + fp = fopen(comp, "r"); + if (!fp) + continue; } if (fstat(fileno(fp), &s)) { -- 2.30.2
