mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 22:36:05 +00:00
binman: Adjust _GetPropTree() parameters
At present this function takes a filename, but it is better to use an Fdt object so that the caller can control this, perhaps obtainint the device tree from a bytearray. Update the method accordingly and also fix a confusing parameter name. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
15a587c9ce
commit
cee02e6ff4
1 changed files with 5 additions and 9 deletions
|
@ -353,21 +353,19 @@ class TestFunctional(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
return struct.unpack('>L', dtb[4:8])[0]
|
return struct.unpack('>L', dtb[4:8])[0]
|
||||||
|
|
||||||
def _GetPropTree(self, dtb_data, node_names):
|
def _GetPropTree(self, dtb, prop_names):
|
||||||
def AddNode(node, path):
|
def AddNode(node, path):
|
||||||
if node.name != '/':
|
if node.name != '/':
|
||||||
path += '/' + node.name
|
path += '/' + node.name
|
||||||
for subnode in node.subnodes:
|
for subnode in node.subnodes:
|
||||||
for prop in subnode.props.values():
|
for prop in subnode.props.values():
|
||||||
if prop.name in node_names:
|
if prop.name in prop_names:
|
||||||
prop_path = path + '/' + subnode.name + ':' + prop.name
|
prop_path = path + '/' + subnode.name + ':' + prop.name
|
||||||
tree[prop_path[len('/binman/'):]] = fdt_util.fdt32_to_cpu(
|
tree[prop_path[len('/binman/'):]] = fdt_util.fdt32_to_cpu(
|
||||||
prop.value)
|
prop.value)
|
||||||
AddNode(subnode, path)
|
AddNode(subnode, path)
|
||||||
|
|
||||||
tree = {}
|
tree = {}
|
||||||
dtb = fdt.Fdt(dtb_data)
|
|
||||||
dtb.Scan()
|
|
||||||
AddNode(dtb.GetRoot(), '')
|
AddNode(dtb.GetRoot(), '')
|
||||||
return tree
|
return tree
|
||||||
|
|
||||||
|
@ -1092,11 +1090,9 @@ class TestFunctional(unittest.TestCase):
|
||||||
"""Test that we can update the device tree with offset/size info"""
|
"""Test that we can update the device tree with offset/size info"""
|
||||||
_, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts',
|
_, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts',
|
||||||
update_dtb=True)
|
update_dtb=True)
|
||||||
props = self._GetPropTree(out_dtb_fname, ['offset', 'size',
|
dtb = fdt.Fdt(out_dtb_fname)
|
||||||
'image-pos'])
|
dtb.Scan()
|
||||||
with open('/tmp/x.dtb', 'wb') as outf:
|
props = self._GetPropTree(dtb, ['offset', 'size', 'image-pos'])
|
||||||
with open(out_dtb_fname) as inf:
|
|
||||||
outf.write(inf.read())
|
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
'image-pos': 0,
|
'image-pos': 0,
|
||||||
'offset': 0,
|
'offset': 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue