From: Luca Weiss <[email protected]>
Add a new Python method wrapping fdt_get_path() from the C API.
This is a backport of dtc commit ed310803ea89 ("pylibfdt: add
FdtRo.get_path()"), without the dtc-side test, which has no counterpart
in U-Boot's test suite.
Signed-off-by: Luca Weiss <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Signed-off-by: David Gibson <[email protected]>
[adapted to U-Boot]
Signed-off-by: Alexey Charkov <[email protected]>
---
scripts/dtc/pylibfdt/libfdt.i_shipped | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped
b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 735a3bab6d9f..634ccd2a829a 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -447,6 +447,29 @@ class FdtRo(object):
"""
return fdt_get_alias(self._fdt, name)
+ def get_path(self, nodeoffset, quiet=()):
+ """Get the full path of a node
+
+ Args:
+ nodeoffset: Node offset to check
+
+ Returns:
+ Full path to the node
+
+ Raises:
+ FdtException if an error occurs
+ """
+ size = 1024
+ while True:
+ ret, path = fdt_get_path(self._fdt, nodeoffset, size)
+ if ret == -NOSPACE:
+ size = size * 2
+ continue
+ err = check_err(ret, quiet)
+ if err:
+ return err
+ return path
+
def parent_offset(self, nodeoffset, quiet=()):
"""Get the offset of a node's parent
@@ -1120,6 +1143,11 @@ typedef uint32_t fdt32_t;
}
}
+%include "cstring.i"
+
+%cstring_output_maxsize(char *buf, int buflen);
+int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
+
/* We have both struct fdt_property and a function fdt_property() */
%warnfilter(302) fdt_property;
--
2.54.0