diff options
author | Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com> | 2019-07-03 10:38:07 +0530 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-07-04 12:56:47 +1000 |
commit | d6de81b81b68f9e559adf42366574233be338fd8 (patch) | |
tree | 6da22dda119c7bec630c75407cd8f208b47ee085 | |
parent | 1c17714dbb3aa43e5b7927dfc073e5e88ae20655 (diff) | |
download | dtc-d6de81b81b68f9e559adf42366574233be338fd8.zip dtc-d6de81b81b68f9e559adf42366574233be338fd8.tar.gz dtc-d6de81b81b68f9e559adf42366574233be338fd8.tar.bz2 |
pylibfdt: Add support for fdt_get_alias()
Add this into the class to simplify use of this function.
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com>
Message-Id: <1562130487-27028-1-git-send-email-appana.durga.rao@xilinx.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | pylibfdt/libfdt.i | 12 | ||||
-rw-r--r-- | tests/pylibfdt_tests.py | 7 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index ecec4dd..feb8c9c 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -431,6 +431,18 @@ class FdtRo(object): """ return fdt_get_phandle(self._fdt, nodeoffset) + def get_alias(self, name): + """Get the full path referenced by a given alias + + Args: + name: name of the alias to lookup + + Returns: + Full path to the node for the alias named 'name', if it exists + None, if the given alias or the /aliases node does not exist + """ + return fdt_get_alias(self._fdt, name) + def parent_offset(self, nodeoffset, quiet=()): """Get the offset of a node's parent diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index c055f01..42f31ba 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -77,6 +77,7 @@ class PyLibfdtBasicTests(unittest.TestCase): """Read in the device tree we use for testing""" self.fdt = _ReadFdt('test_tree1.dtb') self.fdt2 = _ReadFdt('test_props.dtb') + self.fdt3 = _ReadFdt('aliases.dtb') def GetPropList(self, node_path): """Read a list of properties from a node @@ -340,6 +341,12 @@ class PyLibfdtBasicTests(unittest.TestCase): node2 = self.fdt.path_offset('/subnode@2') self.assertEquals(0x2000, self.fdt.get_phandle(node2)) + def testGetAlias(self): + """Test for the get_alias() method""" + self.assertEquals("/subnode@1", self.fdt3.get_alias('s1')) + self.assertEquals("/subnode@1/subsubnode", self.fdt3.get_alias('ss1')) + self.assertEquals("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1')) + def testParentOffset(self): """Test for the parent_offset() method""" self.assertEquals(-libfdt.NOTFOUND, |