[SLOF] [PATCH v2 2/3] board_qemu: move code out of fdt-fix-node-phandle

Greg Kurz groug at kaod.org
Fri Jul 14 08:25:21 AEST 2017


This patch moves the code that actually alter the device tree to a
separate word, for improved readability. While here, it also makes
the comment of fdt-replace-all-phandles more accurate.

Signed-off-by: Greg Kurz <groug at kaod.org>
---
 board-qemu/slof/fdt.fs |   36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
index eff3375c5916..1aeee3d93688 100644
--- a/board-qemu/slof/fdt.fs
+++ b/board-qemu/slof/fdt.fs
@@ -279,8 +279,8 @@ fdt-claim-reserve
    2drop
 ;
 
-\ Replace one FDT phandle "old" with a OF1275 phandle "new" in the
-\ whole tree:
+\ Replace one phandle "old" with a phandle "new" in "node" and recursively
+\ in its child nodes:
 : fdt-replace-all-phandles ( old new node -- )
    \ ." Replacing in " dup node>path type cr
    >r
@@ -308,25 +308,33 @@ fdt-claim-reserve
    3drop
 ;
 
+\ Replace one FDT phandle "val" with a OF1275 phandle "node" in the
+\ whole tree:
+: fdt-update-phandle ( val node -- )
+   >r
+   FALSE TO (fdt-phandle-replaced)
+   r@ s" /" find-node               ( val node root )
+   fdt-replace-all-phandles
+   (fdt-phandle-replaced) IF
+      r@ set-node
+      s" phandle" delete-property
+      s" linux,phandle" delete-property
+   ELSE
+      diagnostic-mode? IF
+         cr ." Warning: Did not replace phandle in " r@ node>path type cr
+      THEN
+   THEN
+r> drop
+;
+
 \ Check whether a node has "phandle" or "linux,phandle" properties
 \ and replace them:
 : fdt-fix-node-phandle  ( node -- )
    >r
-   FALSE TO (fdt-phandle-replaced)
    s" phandle" r@ get-property 0= IF
       decode-int -rot 2drop
       \ ." found phandle: " dup . cr
-      r@ s" /" find-node               ( val node root )
-      fdt-replace-all-phandles
-      (fdt-phandle-replaced) IF
-         r@ set-node
-         s" phandle" delete-property
-         s" linux,phandle" delete-property
-      ELSE
-         diagnostic-mode? IF
-            cr ." Warning: Did not replace phandle in " r@ node>path type cr
-         THEN
-      THEN
+      r@ fdt-update-phandle
    THEN
    r> drop
 ;



More information about the SLOF mailing list