diff options
author | Greg Kurz <groug@kaod.org> | 2017-07-14 08:54:35 +0200 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-07-17 13:51:57 +1000 |
commit | c39657a5f7d502c132a4ae7f407f8281a2ce68e4 (patch) | |
tree | eea6fa3bcc19ee5041752594c885ae605970e5c7 /board-qemu | |
parent | 4c345ef71ecab658a17020c7780dd5a7d01029bf (diff) | |
download | SLOF-c39657a5f7d502c132a4ae7f407f8281a2ce68e4.zip SLOF-c39657a5f7d502c132a4ae7f407f8281a2ce68e4.tar.gz SLOF-c39657a5f7d502c132a4ae7f407f8281a2ce68e4.tar.bz2 |
board_qemu: move code out of fdt-fix-node-phandle
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>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'board-qemu')
-rw-r--r-- | board-qemu/slof/fdt.fs | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/board-qemu/slof/fdt.fs b/board-qemu/slof/fdt.fs index 50beac8..851645e 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 ; |