From patchwork Fri Jun 19 21:11:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 1313361 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pWj81sHmz9sSf for ; Sat, 20 Jun 2020 07:12:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A2F380437; Fri, 19 Jun 2020 23:12:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 1B0AC80679; Fri, 19 Jun 2020 23:12:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2C200801D8 for ; Fri, 19 Jun 2020 23:11:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=walter.lozano@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: wlozano) with ESMTPSA id 09CF92A54E9 From: Walter Lozano To: u-boot@lists.denx.de, sjg@chromium.org, trini@konsulko.com, rayagonda.kokatanur@broadcom.com, marek.vasut@gmail.com, peng.fan@nxp.com, smoch@web.de, agust@denx.de Cc: Walter Lozano Subject: [RFC 2/4] dtoc: add initial support for deleting DTB nodes Date: Fri, 19 Jun 2020 18:11:38 -0300 Message-Id: <20200619211140.5081-3-walter.lozano@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200619211140.5081-1-walter.lozano@collabora.com> References: <20200619211140.5081-1-walter.lozano@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This patch introduce a test for deleting DTB nodes using Python library. Signed-off-by: Walter Lozano --- tools/dtoc/dtb_platdata.py | 28 ++++++++++++++++++++++++++++ tools/dtoc/fdt.py | 3 +++ 2 files changed, 31 insertions(+) diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 1df13b2cd2..d3fb4dcbf2 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -831,6 +831,30 @@ class DtbPlatdata(object): return + def test_del_node(self): + """Test the support of node deletion' + + This function tests the support of node removal by deleting a specific + node name + """ + for n in self._fdt.GetRoot().subnodes: + print('Name', n.name) + #print('Props', n.props) + if n.name == 'board-detect': + n.DelNode() + #self._fdt.GetRoot().subnodes.remove(n) + self._fdt.Scan() + print('') + for n in self._fdt.GetRoot().subnodes: + print('Name', n.name) + #print('Props', n.props) + if n.name == 'serial': + self._fdt.GetRoot().subnodes.remove(n) + + self._fdt.Pack() + self._fdt.Flush() + self._fdt.Sync() + def run_steps(args, dtb_file, config_file, include_disabled, output): """Run all the steps of the dtoc tool @@ -848,6 +872,8 @@ def run_steps(args, dtb_file, config_file, include_disabled, output): skip_scan = False if args == ['shrink']: skip_scan = True + if args == ['test_del_node']: + skip_scan = True plat = DtbPlatdata(dtb_file, config_file, include_disabled) plat.scan_drivers() @@ -867,6 +893,8 @@ def run_steps(args, dtb_file, config_file, include_disabled, output): plat.generate_tables() elif cmd == 'shrink': plat.shrink() + elif cmd == 'test_del_node': + plat.test_del_node() else: raise ValueError("Unknown command '%s': (use: struct, platdata)" % cmd) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 3d4bc3b2ef..b3b626cd4d 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -502,6 +502,9 @@ class Node: for prop in prop_list: prop.Sync(auto_resize) + def DelNode(self): + fdt_obj = self._fdt._fdt_obj + fdt_obj.del_node(self._offset) class Fdt: """Provides simple access to a flat device tree blob using libfdts.