From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 517C2C48BC2 for ; Sun, 27 Jun 2021 23:54:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CC958613B5 for ; Sun, 27 Jun 2021 23:53:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC958613B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7AA9982DC0; Mon, 28 Jun 2021 01:52: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=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="DritiNtL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B6D282D78; Mon, 28 Jun 2021 01:51:39 +0200 (CEST) Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 2357B82CE9 for ; Mon, 28 Jun 2021 01:51:34 +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-ot1-x32b.google.com with SMTP id g19-20020a9d12930000b0290457fde18ad0so16750830otg.1 for ; Sun, 27 Jun 2021 16:51:34 -0700 (PDT) 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=12KuuzgqA54A+iaZ+lB8LgYRq22nkrHQR2rx4e/CjVI=; b=DritiNtLG6JSD7EGDcCN/BjEeMR0x2MGJMyj5vhNuE7cQy+sukoayPtxxsCXHIqGa+ iYCNnDcXClCafRt45nZ2MAGqT4K7ipN6CO5XbnCVLfJ7zCVPhcAaO0PJi4fMMQfKPnAN mDslUhD8iL0o1KxcPm+0Z+r4xCqrpQv1c/iAQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=12KuuzgqA54A+iaZ+lB8LgYRq22nkrHQR2rx4e/CjVI=; b=UaLIZj+f/MdSw3n6jggstcNLt6EGd3vzE+oK8m3yNFoT3RzUd4WzT4EaP36MT4su8c 8SzfG2QlbNgGi4WzdCmD92ZaE4j+D1v4UDMpYdiyUUcXSy9pjt70x6K56jhmYjQFSA/F GYhFUPvYFExIBPQ9I/0+vuY5X50LubTxO+txeAIgLB46m2xu2Bst+1WP/J7ZuKUIvlLP /Lxd9kgBU15eFof9B1Lls8eTLGs1ojG7MiD0UbMoh70PgdmABYqPgARzT9zjHFHET6WC uxpVgwH3I1HvCrsGmgVH3xmUvckgobZjioOtaeKWey/G+9r/hbjG/BgqBeBwObgewANU qvUw== X-Gm-Message-State: AOAM530CRnONB7bRXL9ZsetiAFhJwwy/QEsJA0/nX2coVkcL61UO/QN4 1shy17oMjoaflwMe2tkB+StAdDNQBXpasuAq X-Google-Smtp-Source: ABdhPJzYS9VqdM/zMrCQ8xdpcJgzwxT+4SjGGpIIsjSm1K2QKU9dHOWT/zaP1+YUO4ugs+zijcbI3w== X-Received: by 2002:a05:6830:17d5:: with SMTP id p21mr19164830ota.104.1624837892765; Sun, 27 Jun 2021 16:51:32 -0700 (PDT) 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 bb34sm1297928oob.39.2021.06.27.16.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jun 2021 16:51:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v3 15/16] dtoc: Check that a parent is not missing Date: Sun, 27 Jun 2021 17:51:10 -0600 Message-Id: <20210627175102.v3.15.I11cd6003245319bf9c867b3b6e0feadb1a5d09b1@changeid> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210627235111.485507-1-sjg@chromium.org> References: <20210627235111.485507-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean With of-platdata-inst we want to set up a reference to each devices' parent device, if there is one. If we find that the device has a parent (i.e. is not a root node) but it is not in the list of devices being written, then we cannot create the reference. Report an error in this case, since it indicates that the parent node is either missing a compatible string, is disabled, or perhaps does not have any properties because it was not tagged for SPL. Signed-off-by: Simon Glass --- Changes in v3: - Fix comment to menion u-boot,dm-tpl - Fix 'u-boot,dm-pre-tpl' (it should be u-boot,dm-tpl) tools/dtoc/dtb_platdata.py | 9 ++++++++ tools/dtoc/test/dtoc_test_noparent.dts | 32 ++++++++++++++++++++++++++ tools/dtoc/test_dtoc.py | 10 ++++++++ 3 files changed, 51 insertions(+) create mode 100644 tools/dtoc/test/dtoc_test_noparent.dts diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 2d42480a9a5..869c92b49bf 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -749,6 +749,15 @@ class DtbPlatdata(): break if node.parent and node.parent.parent: + if node.parent not in self._valid_nodes: + # This might indicate that the parent node is not in the + # SPL/TPL devicetree but the child is. For example if we are + # dealing with of-platdata in TPL, the parent has a + # u-boot,dm-tpl tag but the child has u-boot,dm-pre-reloc. In + # this case the child node exists in TPL but the parent does + # not. + raise ValueError("Node '%s' requires parent node '%s' but it is not in the valid list" % + (node.path, node.parent.path)) self.buf('\t.parent\t\t= DM_DEVICE_REF(%s),\n' % node.parent.var_name) if priv_name: diff --git a/tools/dtoc/test/dtoc_test_noparent.dts b/tools/dtoc/test/dtoc_test_noparent.dts new file mode 100644 index 00000000000..e976dd2b8af --- /dev/null +++ b/tools/dtoc/test/dtoc_test_noparent.dts @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test device tree file for dtoc + * + * Copyright 2017 Google, Inc + */ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + i2c@0 { + compatible = "sandbox,i2c"; + u-boot,dm-tpl; + #address-cells = <1>; + #size-cells = <0>; + spl-test { + u-boot,dm-pre-reloc; + compatible = "sandbox,spl-test"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + pmic@9 { + compatible = "sandbox,pmic"; + u-boot,dm-pre-reloc; + reg = <9>; + low-power; + }; + }; + }; +}; diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 0b2805feed2..863ede90b7a 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -1830,3 +1830,13 @@ U_BOOT_DRVINFO(spl_test2) = { dtb_file = get_dtb_file('dtoc_test_single_reg.dts') output = tools.GetOutputFilename('output') self.run_test(['struct'], dtb_file, output) + + def test_missing_parent(self): + """Test detection of a parent node with no properties""" + dtb_file = get_dtb_file('dtoc_test_noparent.dts', capture_stderr=True) + output = tools.GetOutputFilename('output') + with self.assertRaises(ValueError) as exc: + self.run_test(['device'], dtb_file, output, instantiate=True) + self.assertIn("Node '/i2c@0/spl-test/pmic@9' requires parent node " + "'/i2c@0/spl-test' but it is not in the valid list", + str(exc.exception)) -- 2.32.0.93.g670b81a890-goog