[PATCH 1/2] libfdt: overlay: Allow resolving phandle symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Add ability to resolve symbols pointing to phandles instead of strings.

Combining this with existing fixups infrastructure allows creating
symbols in overlays that refer to undefined phandles. This is planned to
be used for addon board chaining [1].

[1] https://lore.kernel.org/linux-arm-kernel/20240702164403.29067-1-afd@xxxxxx/

Signed-off-by: Ayush Singh <ayush@xxxxxxxxxxxxxxx>
---
 libfdt/fdt_overlay.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
index 28b667f..10127be 100644
--- a/libfdt/fdt_overlay.c
+++ b/libfdt/fdt_overlay.c
@@ -395,12 +395,16 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
 	symbol_path = fdt_getprop(fdt, symbols_off, label, &prop_len);
 	if (!symbol_path)
 		return prop_len;
-	
-	symbol_off = fdt_path_offset(fdt, symbol_path);
-	if (symbol_off < 0)
-		return symbol_off;
-	
-	phandle = fdt_get_phandle(fdt, symbol_off);
+
+	if (prop_len == sizeof(uint32_t) && symbol_path[0] != '/') {
+		phandle = fdt32_ld((const fdt32_t *)symbol_path);
+	} else {
+		symbol_off = fdt_path_offset(fdt, symbol_path);
+		if (symbol_off < 0)
+			return symbol_off;
+		phandle = fdt_get_phandle(fdt, symbol_off);
+	}
+
 	if (!phandle)
 		return -FDT_ERR_NOTFOUND;
 

-- 
2.46.0





[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux