aboutsummaryrefslogtreecommitdiff
path: root/pylibfdt
diff options
context:
space:
mode:
authorLuca Weiss <luca@z3ntu.xyz>2022-04-19 21:45:38 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2022-04-20 12:55:14 +1000
commited310803ea893ed0a8bba9c4ff0d9eb0063a8bef (patch)
tree891f3db734b2dc3cb887f1d63cf037687d963fb6 /pylibfdt
parentc001fc01a43e7a06447c06ea3d50bd60641322b8 (diff)
downloaddtc-ed310803ea893ed0a8bba9c4ff0d9eb0063a8bef.zip
dtc-ed310803ea893ed0a8bba9c4ff0d9eb0063a8bef.tar.gz
dtc-ed310803ea893ed0a8bba9c4ff0d9eb0063a8bef.tar.bz2
pylibfdt: add FdtRo.get_path()
Add a new Python method wrapping fdt_get_path() from the C API. Also add a test for the new method. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Message-Id: <20220419194537.63170-1-luca@z3ntu.xyz> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pylibfdt')
-rw-r--r--pylibfdt/libfdt.i28
1 files changed, 28 insertions, 0 deletions
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index ac70762..f9f7e7e 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -443,6 +443,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
@@ -1115,6 +1138,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;