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 65B58C001E0 for ; Sun, 23 Jul 2023 03:44:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BAEC28662E; Sun, 23 Jul 2023 05:44:22 +0200 (CEST) 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="SRSwiEF7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 875CF8664F; Sun, 23 Jul 2023 05:44:16 +0200 (CEST) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 017BA8661B for ; Sun, 23 Jul 2023 05:44:14 +0200 (CEST) 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-io1-xd35.google.com with SMTP id ca18e2360f4ac-786f25bcb40so187048039f.3 for ; Sat, 22 Jul 2023 20:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690083852; x=1690688652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HBqpiD6TrMgrxskqYkR56c8W57jcbM1sP9Hwg/Uedy8=; b=SRSwiEF74Womj1h0gpWDUpGQM8XxKAyO61vFQ9gEmmSA5NYAdLlx0lLSeVNAxPATuV UEuCrB9qxyJ+Q62OUvazqZ6pG4dzwTajIhYNvfHgjDtb4guYmNRIwanu71a2vgO39Gzx ZrWCCnG609Z5YbMHN63G5YO8yTAYBxHAY3n+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690083852; x=1690688652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HBqpiD6TrMgrxskqYkR56c8W57jcbM1sP9Hwg/Uedy8=; b=K4tU+npTKindm41rsii4304r6pfrk6Z7S4OAVCuRwc2ETBzu1KYGjddlO+sp7mK8vu BHcqWx/uHqLYryVjOhjatNw7Z9sZBMJaZ2DOSS0oavnckIOy9QJ8wCcs7SW2V3ydawt5 shU/MDhJHTN3DN33tM66kpOhdhl41JlrXMwZMraViOpZk6Fawm836xu9BuQBTbE/rGv9 caRSoQOxcSWoSztnBdYXWDCfsDgM+GGXclG1mvMHo2xOA8iu+yXEkWhUUtYSMcdBthCu Bh+5Us2CD/zwpFybsclfdVhXyk/2sF8N+EwDoLTSmGSp0ghPBhZeqwDL8lgl9TmxelvI kZgg== X-Gm-Message-State: ABy/qLY0ST9vQ1D2piWzZGu55x/rpG2GuIMmoNT34XDxAbhiLWbmKWRv 3HzMNPbRgUL5GbcXSksmSr8noHtJOOK6RYxsKLk= X-Google-Smtp-Source: APBJJlExFobXutUe5BcP9KVoOlZFjajZkOispQaHCUr1Rsa8s4mvxJvteZ9c5XcHicm3Vge5lAQytQ== X-Received: by 2002:a5d:87d8:0:b0:783:5452:e335 with SMTP id q24-20020a5d87d8000000b007835452e335mr6202766ios.6.1690083852589; Sat, 22 Jul 2023 20:44:12 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id a11-20020a056638018b00b0042b3e04510asm2077384jaq.98.2023.07.22.20.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 20:44:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Neha Malcom Francis , Stefan Herbrechtsmeier , Philippe Reynes , Peng Fan , Simon Glass , Heinrich Schuchardt Subject: [PATCH v2 2/6] dtoc: Make properties dirty when purging them Date: Sat, 22 Jul 2023 21:43:53 -0600 Message-ID: <20230723034406.87673-3-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230723034406.87673-1-sjg@chromium.org> References: <20230723034406.87673-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.8 at phobos.denx.de X-Virus-Status: Clean Without the 'dirty' flag properties are not written back to the devicetree when synced. This means that new properties copied over to a node are not always written out. Fix this and add a test. Signed-off-by: Simon Glass --- (no changes since v1) tools/dtoc/fdt.py | 1 + tools/dtoc/test/dtoc_test_copy.dts | 6 ++++-- tools/dtoc/test_fdt.py | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index fd0f3e94f5c0..2589be990ae9 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -272,6 +272,7 @@ class Prop: the FDT is synced """ self._offset = None + self.dirty = True class Node: """A device tree node diff --git a/tools/dtoc/test/dtoc_test_copy.dts b/tools/dtoc/test/dtoc_test_copy.dts index 36faa9b72b56..8e50c7565928 100644 --- a/tools/dtoc/test/dtoc_test_copy.dts +++ b/tools/dtoc/test/dtoc_test_copy.dts @@ -37,11 +37,12 @@ new-prop; }; - second1 { + second1: second1 { new-prop; }; second4 { + use_second1 = <&second1>; }; }; }; @@ -65,12 +66,13 @@ }; second: second { - second1 { + second_1_bad: second1 { some-prop; }; second2 { some-prop; + use_second1_bad = <&second_1_bad>; }; }; }; diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 3e54694eec9f..84dcd8b5caa5 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -308,7 +308,7 @@ class TestNode(unittest.TestCase): def test_copy_node(self): """Test copy_node() function""" - def do_copy_checks(dtb, dst, expect_none): + def do_copy_checks(dtb, dst, second1_ph_val, expect_none): self.assertEqual( ['/dest/base', '/dest/first@0', '/dest/existing'], [n.path for n in dst.subnodes]) @@ -365,12 +365,22 @@ class TestNode(unittest.TestCase): ['second1', 'second2', 'second3', 'second4'], [n.name for n in second.subnodes]) + # Check the 'second_1_bad' phandle is not copied over + second1 = second.FindNode('second1') + self.assertTrue(second1) + sph = second1.props.get('phandle') + self.assertTrue(sph) + self.assertEqual(second1_ph_val, sph.bytes) + + dtb = fdt.FdtScan(find_dtb_file('dtoc_test_copy.dts')) tmpl = dtb.GetNode('/base') dst = dtb.GetNode('/dest') + second1_ph_val = (dtb.GetNode('/dest/base/second/second1'). + props['phandle'].bytes) dst.copy_node(tmpl) - do_copy_checks(dtb, dst, expect_none=True) + do_copy_checks(dtb, dst, second1_ph_val, expect_none=True) dtb.Sync(auto_resize=True) @@ -378,7 +388,7 @@ class TestNode(unittest.TestCase): new_dtb = fdt.Fdt.FromData(dtb.GetContents()) new_dtb.Scan() dst = new_dtb.GetNode('/dest') - do_copy_checks(new_dtb, dst, expect_none=False) + do_copy_checks(new_dtb, dst, second1_ph_val, expect_none=False) def test_copy_subnodes_from_phandles(self): """Test copy_node() function""" -- 2.41.0.487.g6d72f3e995-goog