From patchwork Fri Jul 14 06:54:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 788152 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 3x83Pg3h9yz9ryk for ; Fri, 14 Jul 2017 16:56:23 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x83Pg2l12zDqm7 for ; Fri, 14 Jul 2017 16:56:23 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from 8.mo173.mail-out.ovh.net (8.mo173.mail-out.ovh.net [46.105.46.122]) (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 3x83Mj0VnwzDr4W for ; Fri, 14 Jul 2017 16:54:41 +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 BE49567569 for ; Fri, 14 Jul 2017 08:54:37 +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 7AA372C0080; Fri, 14 Jul 2017 08:54:35 +0200 (CEST) From: Greg Kurz To: slof@lists.ozlabs.org Date: Fri, 14 Jul 2017 08:54:35 +0200 Message-ID: <150001527527.32021.15036964195019720465.stgit@bahia.lan> In-Reply-To: <150001525887.32021.2559064177797155539.stgit@bahia.lan> References: <150001525887.32021.2559064177797155539.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 X-Ovh-Tracer-Id: 7686800142509054258 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrfedvgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Subject: [SLOF] [PATCH v3 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 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 ;