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: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
880e9ee650
commit
e44bc831e2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user