From patchwork Sat Jul 20 18:23:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1134429 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hE+vo2wG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45rbzK3LXKz9s4Y for ; Sun, 21 Jul 2019 04:30:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 271CEC21E02; Sat, 20 Jul 2019 18:27:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0E730C21DB5; Sat, 20 Jul 2019 18:25:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 49DD3C21E18; Sat, 20 Jul 2019 18:25:11 +0000 (UTC) Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by lists.denx.de (Postfix) with ESMTPS id C6738C21DD7 for ; Sat, 20 Jul 2019 18:25:10 +0000 (UTC) Received: by mail-io1-f44.google.com with SMTP id i10so65180337iol.13 for ; Sat, 20 Jul 2019 11:25:10 -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=0k+QdPYY2bajE19JZ45UF0/Jacu3BSMr5UDJoUaJEAk=; b=hE+vo2wGjgfqAp4lVQ5U1KqylR9CrJ62yeECbYejVodWEI0/x1qKYrNMOF1GG7JvOG ttxZgs/kBAkU1uWI9ngel/v65ZDYseI2wkEliAR6dkgfIP+A69yJ+IELUBULU1qHkTYh FoPg7qWzMqIqo7OI4Q5EFp78ibslRpkQgho8E= 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=0k+QdPYY2bajE19JZ45UF0/Jacu3BSMr5UDJoUaJEAk=; b=oD3DtrCegTYEaMzTiwXblmCrbmVzqBp/rY8brcciC/v9nhaKOenBCHjb/91YXv+Jqu GvY+wUGCeYx+wV8mmLZkn9LVo91XDcLM3/NLiS6p1Um5EnKDiebKiNm9Bwray/0pOD3p Lkc/1G4U9/oG8jUI1fr8zZGw5dXxT2zY6LedNb13zp/j9e27uKYwptgpB3Z4Zztx9Wp1 1g8dknr44SKWpBSZjJ8lKYkvVIjamInIEom61zqSLGNH2K6V62E1VOYqGcPwPHH9xSc2 MuoDz/zM6o55l9zzq4eh6YOfnBa8TIpH9MhDwf/xDKzJS1QchmUUNUq7RCGM7NkRV0Cl em7Q== X-Gm-Message-State: APjAAAXUE99M9m6fgcczFUxoE6iVCNhlHMdDhqvcW4POjNwQwapWL9Kr cVFIOT4mG1qLUxHTaDrs+sTgoFQeRR4= X-Google-Smtp-Source: APXvYqxSGw7/LKjPiKOBR7SJTX6OBsJpsHZZOaz2aP/VP0iXStgiHOc4ymGfCeUp9fN3MwZh1xmKSg== X-Received: by 2002:a6b:7317:: with SMTP id e23mr37679792ioh.37.1563647109670; Sat, 20 Jul 2019 11:25:09 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id z17sm49778933iol.73.2019.07.20.11.25.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 11:25:09 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 20 Jul 2019 12:23:39 -0600 Message-Id: <20190720182416.183626-18-sjg@chromium.org> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog In-Reply-To: <20190720182416.183626-1-sjg@chromium.org> References: <20190720182416.183626-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 17/53] dtoc: Update Fdt.GetNode() to handle the root node X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" This function currently fails if the root node is requested. Requesting the root node is sometimes useful, so fix the bug. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 2 ++ tools/dtoc/test_fdt.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index b341ef3f83b..cd7673c7da0 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -574,6 +574,8 @@ class Fdt: parts = path.split('/') if len(parts) < 2: return None + if len(parts) == 2 and parts[1] == '': + return node for part in parts[1:]: node = node.FindNode(part) if not node: diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index c25248ca1f9..ed2d982a8fc 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -77,11 +77,16 @@ class TestFdt(unittest.TestCase): """Test the GetNode() method""" node = self.dtb.GetNode('/spl-test') self.assertTrue(isinstance(node, fdt.Node)) + node = self.dtb.GetNode('/i2c@0/pmic@9') self.assertTrue(isinstance(node, fdt.Node)) self.assertEqual('pmic@9', node.name) self.assertIsNone(self.dtb.GetNode('/i2c@0/pmic@9/missing')) + node = self.dtb.GetNode('/') + self.assertTrue(isinstance(node, fdt.Node)) + self.assertEqual(0, node.Offset()) + def testFlush(self): """Check that we can flush the device tree out to its file""" fname = self.dtb._fname