Add a method to call fdt_set_name(). Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx> --- pylibfdt/libfdt.i | 15 +++++++++++++++ tests/pylibfdt_tests.py | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index 5ecddba..cf4ed93 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -545,6 +545,21 @@ class Fdt: """ return check_err(fdt_parent_offset(self._fdt, nodeoffset), quiet) + def set_name(self, nodeoffset, name, quiet=()): + """Set the name of a node + + Args: + nodeoffset: Node offset of node to update + name: New node name + + Returns: + Error code, or 0 if OK + + Raises: + FdtException if no parent found or other error occurs + """ + return check_err(fdt_set_name(self._fdt, nodeoffset, name), quiet) + def setprop(self, nodeoffset, prop_name, val, quiet=()): """Set the value of a property diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index a6d9430..57eedcb 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -450,6 +450,13 @@ class PyLibfdtTests(unittest.TestCase): self.assertEquals(TEST_STRING_2, self.fdt.getprop_obj(node, prop).as_str()) + def testSetName(self): + """Test that we can update a node name""" + node = self.fdt.path_offset('/subnode@1') + old_val = self.fdt.get_name(node) + self.fdt.set_name(node, 'test') + self.assertEquals('test', self.fdt.get_name(node)) + if __name__ == "__main__": unittest.main() -- 2.17.0.441.gb46fe60e1d-goog -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html