Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E97B7C433EF for ; Tue, 8 Feb 2022 18:51:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A95083D8E; Tue, 8 Feb 2022 19:50:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JtxCY6Mw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E119783DB7; Tue, 8 Feb 2022 19:50:39 +0100 (CET) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 05B0583DA2 for ; Tue, 8 Feb 2022 19:50:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id d3so14751580ilr.10 for ; Tue, 08 Feb 2022 10:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B87ogGoUVXcau8k+WFC2ug0k9vF20/UKvyNjaruQtEY=; b=JtxCY6Mw1EY8alSv5OkR0hV2t47h8u0nSzQfm9OfJa1rd/6oIcm6uLaiYOUXmungSg 33TfKs1gx2I4hSxJcQx+NfL2sdm69ZNmcBuRh7wjTVnO5QiPFymSUTs4xzhLMqy68KWH HItsHFjbSd3pThyVggvgf15XP3uQmos6FqsHw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B87ogGoUVXcau8k+WFC2ug0k9vF20/UKvyNjaruQtEY=; b=BXGuiYxuD4KqitHS1oXIMKtLlJ4VNEn0Gv9UNtSejgEliq/6MVaf5mvDX7zjyiE3UP AUpoE8+y6yfe8JjUeCuLVqob12crMpJnNTJuJyjoQr+PBzekEvKCnD2QzbeRcmQ29j58 SRaaKisxFA10So6l4LSIwTFWZYjH+bHJ6m/23UuVh3reH7oVB+om8wnI2Y8TPyxBfoNY jUK4ZT/yPuMF4R0wjIU036hJWYeNOk0FZ9mBbwrOxbuAvjKpeAgxvUbsy+REq5cZE4LW 3mylS274CpyvVpvW6YsbeCsv78aw07tHZihOQ+59JebU+CZKjAJ5fCMvNfnBfB/k4+Q0 k/nw== X-Gm-Message-State: AOAM5334oZKB42dwwghxOHLcTvUSaG3xtFPHJiASPplKAl3sJX8NgqPt vtjl0lYzIFFhv/CgkWlB5aNCMnTlUQ8+8w== X-Google-Smtp-Source: ABdhPJxObbX2A0dTCjAhy869zaAV4qrLUUl05zxif1TfceKKDWsIqs8+depcKXVwvvhgEN51GKob1w== X-Received: by 2002:a05:6e02:1c4c:: with SMTP id d12mr2937255ilg.293.1644346232688; Tue, 08 Feb 2022 10:50:32 -0800 (PST) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id q2sm2911844ilt.33.2022.02.08.10.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:50:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: huang lin , Jeffy Chen , Simon Glass , Kever Yang , Philipp Tomsich , Alper Nebi Yasak , Tom Rini , Roger Quadros , Philippe Reynes , Ivan Mikhaylov , Walter Lozano Subject: [PATCH 08/24] dtoc: Allow deleting nodes and adding them in the same sync Date: Tue, 8 Feb 2022 11:49:52 -0700 Message-Id: <20220208185008.35843-7-sjg@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208185008.35843-1-sjg@chromium.org> References: <20220208185008.35843-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This does not work at present, since the current algorithm assumes that either there are no nodes or all nodes have an offset. If a node is new, but an old node is still in the tree, then syncing fails due to this assumption. Fix it and add a test. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 2 ++ tools/dtoc/test_fdt.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 8108a86c09..98d6e636ea 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -356,6 +356,8 @@ class Node: offset = fdt_obj.first_subnode(self._offset, QUIET_NOTFOUND) for subnode in self.subnodes: + if subnode._offset is None: + continue if subnode.name != fdt_obj.get_name(offset): raise ValueError('Internal error, node name mismatch %s != %s' % (subnode.name, fdt_obj.get_name(offset))) diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 22e23c40f5..c8fe5fc1de 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -272,6 +272,17 @@ class TestNode(unittest.TestCase): self.dtb.Sync(auto_resize=True) + def testAddOneNode(self): + """Testing deleting and adding a subnode before syncing""" + subnode = self.node.AddSubnode('subnode') + self.node.AddSubnode('subnode2') + self.dtb.Sync(auto_resize=True) + + # Delete a node and add a new one + subnode.Delete() + self.node.AddSubnode('subnode3') + self.dtb.Sync() + def testRefreshNameMismatch(self): """Test name mismatch when syncing nodes and properties""" prop = self.node.AddInt('integer-a', 12) -- 2.35.0.263.gb82422642f-goog