diff mbox

[v3,2/3] board_qemu: move code out of fdt-fix-node-phandle

Message ID 150001527527.32021.15036964195019720465.stgit@bahia.lan
State Accepted
Headers show

Commit Message

Greg Kurz July 14, 2017, 6:54 a.m. UTC
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@kaod.org>
---
 board-qemu/slof/fdt.fs |   36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs
index 50beac85e451..851645eae299 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 nip nip
       \ ." 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
 ;