diff options
| author | Michael C. Pratt <[email protected]> | 2026-09-02 08:24:57 +0000 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-09-04 12:21:05 -0600 |
| commit | 358c3dc571ee706d8c641cfb092a4b9bc19b9c60 (patch) | |
| tree | f3e61a9e2544e3dd94fc9c3c33906569d62446fe | |
| parent | e53952e6c60372ba340aff266a84c65b6b574511 (diff) | |
fw_env: allow detection of NVMEM device using layout node compatible string
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 devicetree 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 NVMEM cells.
Signed-off-by: Michael C. Pratt <[email protected]>
| -rw-r--r-- | tools/env/fw_env.c | 9 |
1 files changed, 8 insertions, 1 deletions
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)) { |
