From patchwork Thu Jul 13 22:25:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 788015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x7rrz30vSz9s82 for ; Fri, 14 Jul 2017 09:00:51 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x7rrz1NfbzDqlC for ; Fri, 14 Jul 2017 09:00:51 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org X-Greylist: delayed 2110 seconds by postgrey-1.36 at bilbo; Fri, 14 Jul 2017 09:00:46 AEST Received: from 6.mo173.mail-out.ovh.net (6.mo173.mail-out.ovh.net [46.105.43.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3x7rrt6kmMzDqg2 for ; Fri, 14 Jul 2017 09:00:46 +1000 (AEST) Received: from player687.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 4B1386731D for ; Fri, 14 Jul 2017 00:25:24 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player687.ha.ovh.net (Postfix) with ESMTPA id 142A12C0073; Fri, 14 Jul 2017 00:25:22 +0200 (CEST) From: Greg Kurz To: slof@lists.ozlabs.org Date: Fri, 14 Jul 2017 00:25:21 +0200 Message-ID: <149998472186.13629.14206059622188298023.stgit@bahia.lan> In-Reply-To: <149998470010.13629.16124878075303408145.stgit@bahia.lan> References: <149998470010.13629.16124878075303408145.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 17533639252901337394 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrfedvgddukecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Subject: [SLOF] [PATCH v2 2/3] board_qemu: move code out of fdt-fix-node-phandle X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 --- 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 ;