Browse Source

pylibfdt: Add support for fdt_get_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
Simon Glass 7 years ago committed by David Gibson
parent
commit
a198af8034
  1. 12
      pylibfdt/libfdt.i
  2. 6
      tests/pylibfdt_tests.py

12
pylibfdt/libfdt.i

@ -348,6 +348,18 @@ class Fdt:
return pdata return pdata
return bytearray(pdata[0]) return bytearray(pdata[0])


def get_phandle(self, nodeoffset):
"""Get the phandle of a node

Args:
nodeoffset: Node offset to check

Returns:
phandle of node, or 0 if the node has no phandle or another error
occurs
"""
return fdt_get_phandle(self._fdt, nodeoffset)



class Property: class Property:
"""Holds a device tree property name and value. """Holds a device tree property name and value.

6
tests/pylibfdt_tests.py

@ -289,5 +289,11 @@ class PyLibfdtTests(unittest.TestCase):
node2 = self.fdt.path_offset('/subnode@2') node2 = self.fdt.path_offset('/subnode@2')
self.assertEquals(0x2000, libfdt.fdt_get_phandle(self.fdt._fdt, node2)) self.assertEquals(0x2000, libfdt.fdt_get_phandle(self.fdt._fdt, node2))


def testGetPhandle(self):
"""Test for the get_phandle() method"""
self.assertEquals(0, self.fdt.get_phandle(0))
node2 = self.fdt.path_offset('/subnode@2')
self.assertEquals(0x2000, self.fdt.get_phandle(node2))

if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

Loading…
Cancel
Save