pylibfdt: Add support for fdt_node_offset_by_phandle()
Add this into the class to simplify use of this function. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>main
parent
a3ae437236
commit
46f31b65b3
|
|
@ -375,6 +375,20 @@ class Fdt:
|
||||||
"""
|
"""
|
||||||
return check_err(fdt_parent_offset(self._fdt, nodeoffset), quiet)
|
return check_err(fdt_parent_offset(self._fdt, nodeoffset), quiet)
|
||||||
|
|
||||||
|
def node_offset_by_phandle(self, phandle, quiet=()):
|
||||||
|
"""Get the offset of a node with the given phandle
|
||||||
|
|
||||||
|
Args:
|
||||||
|
phandle: Phandle to search for
|
||||||
|
quiet: Errors to ignore (empty to raise on all errors)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The offset of node with that phandle, if any
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
FdtException if no node found or other error occurs
|
||||||
|
"""
|
||||||
|
return check_err(fdt_node_offset_by_phandle(self._fdt, phandle), quiet)
|
||||||
|
|
||||||
class Property:
|
class Property:
|
||||||
"""Holds a device tree property name and value.
|
"""Holds a device tree property name and value.
|
||||||
|
|
|
||||||
|
|
@ -308,5 +308,15 @@ class PyLibfdtTests(unittest.TestCase):
|
||||||
node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
|
node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
|
||||||
self.assertEquals(node1, self.fdt.parent_offset(node2))
|
self.assertEquals(node1, self.fdt.parent_offset(node2))
|
||||||
|
|
||||||
|
def testNodeOffsetByPhandle(self):
|
||||||
|
"""Test for the node_offset_by_phandle() method"""
|
||||||
|
self.assertEquals(-libfdt.NOTFOUND,
|
||||||
|
self.fdt.node_offset_by_phandle(1, QUIET_NOTFOUND))
|
||||||
|
node1 = self.fdt.path_offset('/subnode@2')
|
||||||
|
self.assertEquals(node1, self.fdt.node_offset_by_phandle(0x2000))
|
||||||
|
node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
|
||||||
|
self.assertEquals(node2, self.fdt.node_offset_by_phandle(0x2001))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue