Browse Source

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>
main
Simon Glass 7 years ago committed by David Gibson
parent
commit
f0f8c91698
  1. 144
      pylibfdt/libfdt.i

144
pylibfdt/libfdt.i

@ -185,6 +185,52 @@ class Fdt: @@ -185,6 +185,52 @@ class Fdt:
"""
return bytearray(self._fdt)

def first_subnode(self, nodeoffset, quiet=()):
"""Find the first subnode of a parent node

Args:
nodeoffset: Node offset of parent node
quiet: Errors to ignore (empty to raise on all errors)

Returns:
The offset of the first subnode, if any

Raises:
FdtException if no subnodes found or other error occurs
"""
return check_err(fdt_first_subnode(self._fdt, nodeoffset), quiet)

def next_subnode(self, nodeoffset, quiet=()):
"""Find the next subnode

Args:
nodeoffset: Node offset of previous subnode
quiet: Errors to ignore (empty to raise on all errors)

Returns:
The offset of the next subnode, if any

Raises:
FdtException if no more subnodes found or other error occurs
"""
return check_err(fdt_next_subnode(self._fdt, nodeoffset), quiet)

def totalsize(self):
"""Return the total size of the device tree

Returns:
Total tree size in bytes
"""
return check_err(fdt_totalsize(self._fdt))

def off_dt_struct(self):
"""Return the start of the device tree struct area

Returns:
Start offset of struct area
"""
return check_err(fdt_off_dt_struct(self._fdt))

def subnode_offset(self, parentoffset, name, quiet=()):
"""Get the offset of a named subnode

@ -217,6 +263,20 @@ class Fdt: @@ -217,6 +263,20 @@ class Fdt:
"""
return check_err(fdt_path_offset(self._fdt, path), quiet)

def get_name(self, nodeoffset):
"""Get the name of a node

Args:
nodeoffset: Offset of node to check

Returns:
Node name

Raises:
FdtException on error (e.g. nodeoffset is invalid)
"""
return check_err_null(fdt_get_name(self._fdt, nodeoffset))[0]

def first_property_offset(self, nodeoffset, quiet=()):
"""Get the offset of the first property in a node offset

@ -251,20 +311,6 @@ class Fdt: @@ -251,20 +311,6 @@ class Fdt:
return check_err(fdt_next_property_offset(self._fdt, prop_offset),
quiet)

def get_name(self, nodeoffset):
"""Get the name of a node

Args:
nodeoffset: Offset of node to check

Returns:
Node name

Raises:
FdtException on error (e.g. nodeoffset is invalid)
"""
return check_err_null(fdt_get_name(self._fdt, nodeoffset))[0]

def get_property_by_offset(self, prop_offset, quiet=()):
"""Obtains a property that can be examined

@ -285,52 +331,6 @@ class Fdt: @@ -285,52 +331,6 @@ class Fdt:
return pdata
return Property(pdata[0], pdata[1])

def first_subnode(self, nodeoffset, quiet=()):
"""Find the first subnode of a parent node

Args:
nodeoffset: Node offset of parent node
quiet: Errors to ignore (empty to raise on all errors)

Returns:
The offset of the first subnode, if any

Raises:
FdtException if no subnode found or other error occurs
"""
return check_err(fdt_first_subnode(self._fdt, nodeoffset), quiet)

def next_subnode(self, nodeoffset, quiet=()):
"""Find the next subnode

Args:
nodeoffset: Node offset of previous subnode
quiet: Errors to ignore (empty to raise on all errors)

Returns:
The offset of the next subnode, if any

Raises:
FdtException if no more subnode found or other error occurs
"""
return check_err(fdt_next_subnode(self._fdt, nodeoffset), quiet)

def totalsize(self):
"""Return the total size of the device tree

Returns:
Total tree size in bytes
"""
return check_err(fdt_totalsize(self._fdt))

def off_dt_struct(self):
"""Return the start of the device tree struct area

Returns:
Start offset of struct area
"""
return check_err(fdt_off_dt_struct(self._fdt))

def pack(self, quiet=()):
"""Pack the device tree to remove unused space

@ -344,18 +344,6 @@ class Fdt: @@ -344,18 +344,6 @@ class Fdt:
"""
return check_err(fdt_pack(self._fdt), quiet)

def delprop(self, nodeoffset, prop_name):
"""Delete a property from a node

Args:
nodeoffset: Node offset containing property to delete
prop_name: Name of property to delete

Raises:
FdtError if the property does not exist, or another error occurs
"""
return check_err(fdt_delprop(self._fdt, nodeoffset, prop_name))

def getprop(self, nodeoffset, prop_name, quiet=()):
"""Get a property from a node

@ -404,6 +392,18 @@ class Fdt: @@ -404,6 +392,18 @@ class Fdt:
"""
return check_err(fdt_parent_offset(self._fdt, nodeoffset), quiet)

def delprop(self, nodeoffset, prop_name):
"""Delete a property from a node

Args:
nodeoffset: Node offset containing property to delete
prop_name: Name of property to delete

Raises:
FdtError if the property does not exist, or another error occurs
"""
return check_err(fdt_delprop(self._fdt, nodeoffset, prop_name))

def node_offset_by_phandle(self, phandle, quiet=()):
"""Get the offset of a node with the given phandle


Loading…
Cancel
Save