提交 e44bc831 编写于 作者: S Simon Glass

dtoc: Update Fdt.GetNode() to handle the root node

This function currently fails if the root node is requested. Requesting
the root node is sometimes useful, so fix the bug.
Signed-off-by: NSimon Glass <sjg@chromium.org>
上级 880e9ee6
......@@ -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:
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册