Commit graph

11 commits

Author SHA1 Message Date
Simon Glass
582a7159a5 pylibfdt: Add support for fdt_next_node()
This function requires a bit of typemap effort to get the depth parameter
to work correctly. Add support for it, along with a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-08 22:26:03 +10:00
Simon Glass
f0f8c91698 pylibfdt: Reorder functions to match libfdt.h
The ordering of the Python functions loosely matches the corresponding
function in the C header file, but not exactly. As we add more functions
it is easier to track what is missing if they are in the same order.

Move some functions around to achieve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-08 22:25:02 +10:00
Simon Glass
64a69d1239 pylibfdt: Return string instead of bytearray from getprop()
The return value is not actually mutable, so it seems more correct to
return bytes rather than a bytearray.

Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-08 13:43:52 +10:00
Simon Glass
f0be81bd8d Make Property a subclass of bytearray
It is annoying to have to add .value when we want the value of a Property.
Make Property a subclass of bytearray so that it can be used directly when
the value is required.

Fix the Property class comment while we are here.

Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-04 18:20:02 +10:00
Simon Glass
24b1f3f064 pylibfdt: Add a method to access the device tree directly
When calling libfdt functions which are not supported by the Fdt class it
is necessary to get direct access to the device tree data. At present this
requries using the internal _fdt member. Add a new method to provide
public access to this, without allowing the data to be changed.

Note that a bytearray type is returned rather than str, since the swig
types are set up for bytearray to map correctly to const void *.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-06-04 18:18:38 +10:00
Simon Glass
5bed86aee9 pylibfdt: Add support for fdt_subnode_offset()
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>
2017-08-21 10:17:57 +10:00
Simon Glass
46f31b65b3 pylibfdt: Add support for fdt_node_offset_by_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>
2017-08-21 10:00:44 +10:00
Simon Glass
a3ae437236 pylibfdt: Add support for fdt_parent_offset()
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>
2017-08-21 10:00:44 +10:00
Simon Glass
a198af8034 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>
2017-08-21 10:00:44 +10:00
Simon Glass
ab78860f09 pylibfdt: Add stdint include to fix uint32_t
Some types used by libfdt.h are not understood the Python module since
they are defined outside it. An example is an attempt to do this:

   import libfdt
   result = libfdt.fdt_node_offset_by_phandle(fdt, phandle)

This results in:

TypeError: in method 'fdt_node_offset_by_phandle', argument 2 of
	type 'uint32_t'

Include the standard integer header file to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-08-15 13:47:24 +10:00
Simon Glass
1c5170d3a4 pylibfdt: Rename libfdt.swig to libfdt.i
The .i extension allows Python distutils to automatically handle the swig
file. Rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-04-07 15:43:34 +10:00
Renamed from pylibfdt/libfdt.swig (Browse further)