Skip to contentSkip to conversation

fw_env: allow detection of NVMEM device using layout node compatible string

PATCH Superseded Michael C. Pratt 1 participant 1 message Aug 20

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 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.

---
 tools/env/fw_env.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tools/env/fw_env.c +8 -1
index 49a068d91cc..8810b0e94dc 100644
@@ -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)) {
Signature · 1 line
2.30.2