dtoc: Add a function to obtain a list of phandles
Add a function which can decode a property containing a list of phandles. This is useful for finding nodes linked to a property. Also provide a way to look up a single phandle and get the Fdt object from a Node. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -171,6 +171,24 @@ def GetByte(node, propname, default=None):
|
||||
(node.name, propname, len(value), 1))
|
||||
return ord(value[0])
|
||||
|
||||
def GetPhandleList(node, propname):
|
||||
"""Get a list of phandles from a property
|
||||
|
||||
Args:
|
||||
node: Node object to read from
|
||||
propname: property name to read
|
||||
|
||||
Returns:
|
||||
List of phandles read, each an integer
|
||||
"""
|
||||
prop = node.props.get(propname)
|
||||
if not prop:
|
||||
return None
|
||||
value = prop.value
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
return [fdt32_to_cpu(v) for v in value]
|
||||
|
||||
def GetDatatype(node, propname, datatype):
|
||||
"""Get a value of a given type from a property
|
||||
|
||||
|
Reference in New Issue
Block a user