DeviceTree Kernel API
Core functions #
of_find_all_nodes() #
struct device_node * Get next node in global list
Parameters
struct device_node *prev: Previous node or NULL to start iterationof_node_put()will be called on it
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_machine_compatible_match() #
bool Test root of device tree against a compatible array
Parameters
const char *const *compats: NULL terminated array of compatible strings to look for in root node's compatible property.
Description
Returns true if the root node has any of the given compatible values in its compatible property.
of_machine_device_match() #
bool Test root of device tree against a of_device_id array
Parameters
const struct of_device_id *matches: NULL terminated array of of_device_id match structures to search in
Description
Returns true if the root node has any of the given compatible values in its compatible property.
of_machine_get_match_data() #
const void * Tell if root of device tree has a matching of_match structure
Parameters
const struct of_device_id *matches: NULL terminated array of of_device_id match structures to search in
Description
Returns data associated with matched entry or NULL
of_device_is_available() #
bool check if a device is available for use
Parameters
const struct device_node *device: Node to check for availability
Return
True if the status property is absent or set to "okay" or "ok", false otherwise
of_device_is_big_endian() #
bool check if a device has BE registers
Parameters
const struct device_node *device: Node to check for endianness
Return
True if the device has a "big-endian" property, or if the kernel was compiled for BE and the device has a "native-endian" property. Returns false otherwise.
Description
Callers would nominally use ioread32be/iowrite32be if
of_device_is_big_endian() == true, or readl/writel otherwise.
of_get_parent() #
struct device_node * Get a node's parent if any
Parameters
const struct device_node *node: Node to get parent
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_get_next_parent() #
struct device_node * Iterate to a node's parent
Parameters
struct device_node *node: Node to get parent of
Description
This is like of_get_parent() except that it drops the
refcount on the passed node, making it suitable for iterating
through a node's parents.
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_get_next_child() #
struct device_node * Iterate a node childs
Parameters
const struct device_node *node: parent nodestruct device_node *prev: previous child of the parent node, or NULL to get first
Return
A node pointer with refcount incremented, use of_node_put() on
it when done. Returns NULL when prev is the last child. Decrements the
refcount of prev.
of_get_next_child_with_prefix() #
struct device_node * Find the next child node with prefix
Parameters
const struct device_node *node: parent nodestruct device_node *prev: previous child of the parent node, or NULL to get firstconst char *prefix: prefix that the node name should have
Description
This function is like of_get_next_child(), except that it automatically
skips any nodes whose name doesn't have the given prefix.
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_get_next_available_child() #
struct device_node * Find the next available child node
Parameters
const struct device_node *node: parent nodestruct device_node *prev: previous child of the parent node, or NULL to get first
Description
This function is like of_get_next_child(), except that it
automatically skips any disabled nodes (i.e. status = "disabled").
of_get_next_reserved_child() #
struct device_node * Find the next reserved child node
Parameters
const struct device_node *node: parent nodestruct device_node *prev: previous child of the parent node, or NULL to get first
Description
This function is like of_get_next_child(), except that it
automatically skips any disabled nodes (i.e. status = "disabled").
of_get_next_cpu_node() #
struct device_node * Iterate on cpu nodes
Parameters
struct device_node *prev: previous child of the /cpus node, or NULL to get first
Description
Unusable CPUs (those with the status property set to "fail" or "fail-...") will be skipped.
Return
A cpu node pointer with refcount incremented, use of_node_put()
on it when done. Returns NULL when prev is the last child. Decrements
the refcount of prev.
of_get_compatible_child() #
struct device_node * Find compatible child node
Parameters
const struct device_node *parent: parent nodeconst char *compatible: compatible string
Description
Lookup child node whose compatible property contains the given compatible string.
Return
a node pointer with refcount incremented, use of_node_put() on it
when done; or NULL if not found.
of_get_child_by_name() #
struct device_node * Find the child node by name for a given parent
Parameters
const struct device_node *node: parent nodeconst char *name: child name to look for.
Description
This function looks for child node for given matching name
Return
A node pointer if found, with refcount incremented, use
of_node_put() on it when done.
Returns NULL if node is not found.
of_get_available_child_by_name() #
struct device_node * Find the available child node by name for a given parent
Parameters
const struct device_node *node: parent nodeconst char *name: child name to look for.
Description
This function looks for child node for given matching name and checks the device's availability for use.
Return
A node pointer if found, with refcount incremented, use
of_node_put() on it when done.
Returns NULL if node is not found.
of_find_node_opts_by_path() #
struct device_node * Find a node matching a full OF path
Parameters
const char *path: Either the full path to match, or if the path does not start with '/', the name of a property of the /aliases node (an alias). In the case of an alias, the node matching the alias' value will be returned.const char **opts: Address of a pointer into which to store the start of an options string appended to the end of the path with a ':' separator.
Description
- Valid paths:
- /foo/bar Full path
- foo Valid alias
- foo/bar Valid alias + relative path
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_find_node_by_name() #
struct device_node * Find a node by its "name" property
Parameters
struct device_node *from: The node to start searching from or NULL; the node you pass will not be searched, only the next one will. Typically, you pass what the previous call returned.of_node_put()will be called on from.const char *name: The name string to match against
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_find_node_by_type() #
struct device_node * Find a node by its "device_type" property
Parameters
struct device_node *from: The node to start searching from, or NULL to start searching the entire device tree. The node you pass will not be searched, only the next one will; typically, you pass what the previous call returned.of_node_put()will be called on from for you.const char *type: The type string to match against
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_find_compatible_node() #
struct device_node * Find a node based on type and one of the tokens in its "compatible" property
Parameters
struct device_node *from: The node to start searching from or NULL, the node you pass will not be searched, only the next one will; typically, you pass what the previous call returned.of_node_put()will be called on itconst char *type: The type string to match "device_type" or NULL to ignoreconst char *compatible: The string to match to one of the tokens in the device "compatible" list.
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_find_node_with_property() #
struct device_node * Find a node which has a property with the given name.
Parameters
struct device_node *from: The node to start searching from or NULL, the node you pass will not be searched, only the next one will; typically, you pass what the previous call returned.of_node_put()will be called on itconst char *prop_name: The name of the property to look for.
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_match_node() #
const struct of_device_id * Tell if a device_node has a matching of_match structure
Parameters
const struct of_device_id *matches: array of of device match structures to search inconst struct device_node *node: the of device structure to match against
Description
Low level utility function used by device matching.
of_find_matching_node_and_match() #
struct device_node * Find a node based on an of_device_id match table.
Parameters
struct device_node *from: The node to start searching from or NULL, the node you pass will not be searched, only the next one will; typically, you pass what the previous call returned.of_node_put()will be called on itconst struct of_device_id *matches: array of of device match structures to search inconst struct of_device_id **match: Updated to point at the matches entry which matched
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_alias_from_compatible() #
int Lookup appropriate alias for a device node depending on compatible
Parameters
const struct device_node *node: pointer to a device tree nodechar *alias: Pointer to buffer that alias value will be copied intoint len: Length of alias value
Description
Based on the value of the compatible property, this routine will attempt to choose an appropriate alias value for a particular device tree node. It does this by stripping the manufacturer prefix (as delimited by a ',') from the first entry in the compatible list property.
Note
The matching on just the "product" side of the compatible is a relic from I2C and SPI. Please do not add any new user.
Return
This routine returns 0 on success, <0 on failure.
of_find_node_by_phandle() #
struct device_node * Find a node given a phandle
Parameters
phandle handle: phandle of the node to find
Return
A node pointer with refcount incremented, use
of_node_put() on it when done.
of_parse_phandle_with_args_map() #
int Find a node pointed by phandle in a list and remap it
Parameters
const struct device_node *np: pointer to a device tree node containing a listconst char *list_name: property name that contains a listconst char *stem_name: stem of property names that specify phandles' arguments countint index: index of a phandle to parse outstruct of_phandle_args *out_args: optional pointer to output arguments structure (will be filled)
Description
This function is useful to parse lists of phandles and their arguments.
Returns 0 on success and fills out_args, on error returns appropriate errno
value. The difference between this function and of_parse_phandle_with_args()
is that this API remaps a phandle if the node the phandle points to has
a <stem_name>-map property.
Caller is responsible to call of_node_put() on the returned out_args->np
pointer.
Example:
phandle1: node1 {
#list-cells = <2>;
};
phandle2: node2 {
#list-cells = <1>;
};
phandle3: node3 {
#list-cells = <1>;
list-map = <0 &phandle2 3>,
<1 &phandle2 2>,
<2 &phandle1 5 1>;
list-map-mask = <0x3>;
};
node4 {
list = <&phandle1 1 2 &phandle3 0>;
};
To get a device_node of the node2 node you may call this:
of_parse_phandle_with_args(node4, "list", "list", 1, args);
of_count_phandle_with_args() #
int Find the number of phandles references in a property
Parameters
const struct device_node *np: pointer to a device tree node containing a listconst char *list_name: property name that contains a listconst char *cells_name: property name that specifies phandles' arguments count
Return
The number of phandle + argument tuples within a property. It is a typical pattern to encode a list of phandle and variable arguments into a single property. The number of arguments is encoded by a property in the phandle-target node. For example, a gpios property would contain a list of GPIO specifies consisting of a phandle and 1 or more arguments. The number of arguments are determined by the #gpio-cells property in the node pointed to by the phandle.
of_add_property() #
int Add a property to a node
Parameters
struct device_node *np: Caller's Device Nodestruct property *prop: Property to add
of_remove_property() #
int Remove a property from a node.
Parameters
struct device_node *np: Caller's Device Nodestruct property *prop: Property to remove
Description
Note that we don't actually remove it, since we have given out who-knows-how-many pointers to the data using get-property. Instead we just move the property to the "dead properties" list, so it won't be found any more.
of_alias_get_id() #
int Get alias id for the given device_node
Parameters
const struct device_node *np: Pointer to the given device_nodeconst char *stem: Alias stem of the given device_node
Description
The function travels the lookup table to get the alias id for the given device_node and alias stem.
Return
The alias id if found.
of_alias_get_highest_id() #
int Get highest alias id for the given stem
Parameters
const char *stem: Alias stem to be examined
Description
The function travels the lookup table to get the highest alias id for the given alias stem. It returns the alias id if found.
of_console_check() #
bool Test and setup console for DT setup
Parameters
const struct device_node *dn: Pointer to device nodechar *name: Name to use for preferred console without index. ex. "ttyS"int index: Index to use for preferred console.
Description
Check if the given device node matches the stdout-path property in the /chosen node. If it does then register it as the preferred console.
Return
TRUE if console successfully setup. Otherwise return FALSE.
of_map_id() #
int Translate an ID through a downstream mapping.
Parameters
const struct device_node *np: root complex device node.u32 id: device ID to map.const char *map_name: property name of the map to use.const char *map_mask_name: optional property name of the mask to use.struct device_node **target: optional pointer to a target device node.u32 *id_out: optional pointer to receive the translated ID.
Description
Given a device ID, look up the appropriate implementation-defined platform ID and/or the target device which receives transactions on that ID, as per the "iommu-map" and "msi-map" bindings. Either of target or id_out may be NULL if only the other is required. If target points to a non-NULL device node pointer, only entries targeting that node will be matched; if it points to a NULL value, it will receive the device node of the first matching target phandle, with a reference held.
Return
0 on success or a standard error code on failure.
of_node_init() #
void initialize a devicetree node
Parameters
struct device_node *node: Pointer to device node that has been created bykzalloc()
Description
On return the device_node refcount is set to one. Use of_node_put()
on node when done to free the memory allocated for it. If the node
is NOT a dynamic node the memory will not be freed. The decision of
whether to free the memory will be done by node->release(), which is
of_node_release().
of_machine_is_compatible() #
bool Test root of device tree for a given compatible value
Parameters
const char *compat: compatible string to look for in root node's compatible property.
Return
true if the root node has the given value in its compatible property.
of_parse_phandle() #
struct device_node * Resolve a phandle property to a device_node pointer
Parameters
const struct device_node *np: Pointer to device node holding phandle propertyconst char *phandle_name: Name of property holding a phandle valueint index: For properties holding a table of phandles, this is the index into the table
Return
The device_node pointer with refcount incremented. Use
of_node_put() on it when done.
of_parse_phandle_with_args() #
int Find a node pointed by phandle in a list
Parameters
const struct device_node *np: pointer to a device tree node containing a listconst char *list_name: property name that contains a listconst char *cells_name: property name that specifies phandles' arguments countint index: index of a phandle to parse outstruct of_phandle_args *out_args: optional pointer to output arguments structure (will be filled)
Description
This function is useful to parse lists of phandles and their arguments. Returns 0 on success and fills out_args, on error returns appropriate errno value.
Caller is responsible to call of_node_put() on the returned out_args->np
pointer.
Example:
phandle1: node1 {
#list-cells = <2>;
};
phandle2: node2 {
#list-cells = <1>;
};
node3 {
list = <&phandle1 1 2 &phandle2 3>;
};
To get a device_node of the node2 node you may call this:
of_parse_phandle_with_args(node3, "list", "#list-cells", 1, args);
of_parse_phandle_with_fixed_args() #
int Find a node pointed by phandle in a list
Parameters
const struct device_node *np: pointer to a device tree node containing a listconst char *list_name: property name that contains a listint cell_count: number of argument cells following the phandleint index: index of a phandle to parse outstruct of_phandle_args *out_args: optional pointer to output arguments structure (will be filled)
Description
This function is useful to parse lists of phandles and their arguments. Returns 0 on success and fills out_args, on error returns appropriate errno value.
Caller is responsible to call of_node_put() on the returned out_args->np
pointer.
Example:
phandle1: node1 {
};
phandle2: node2 {
};
node3 {
list = <&phandle1 0 2 &phandle2 2 3>;
};
To get a device_node of the node2 node you may call this:
of_parse_phandle_with_fixed_args(node3, "list", 2, 1, args);
of_parse_phandle_with_optional_args() #
int Find a node pointed by phandle in a list
Parameters
const struct device_node *np: pointer to a device tree node containing a listconst char *list_name: property name that contains a listconst char *cells_name: property name that specifies phandles' arguments countint index: index of a phandle to parse outstruct of_phandle_args *out_args: optional pointer to output arguments structure (will be filled)
Description
Same as of_parse_phandle_with_args() except that if the cells_name property
is not found, cell_count of 0 is assumed.
This is used to useful, if you have a phandle which didn't have arguments before and thus doesn't have a '#*-cells' property but is now migrated to having arguments while retaining backwards compatibility.
of_phandle_args_equal() #
bool Compare two of_phandle_args
Parameters
const struct of_phandle_args *a1: First of_phandle_args to compareconst struct of_phandle_args *a2: Second of_phandle_args to compare
Return
True if a1 and a2 are the same (same node pointer, same phandle args), false otherwise.
of_property_count_u8_elems() #
int Count the number of u8 elements in a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a property in a device node and count the number of u8 elements in it.
Return
The number of elements on success, -EINVAL if the property does not exist or its length does not match a multiple of u8 and -ENODATA if the property does not have a value.
of_property_count_u16_elems() #
int Count the number of u16 elements in a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a property in a device node and count the number of u16 elements in it.
Return
The number of elements on success, -EINVAL if the property does not exist or its length does not match a multiple of u16 and -ENODATA if the property does not have a value.
of_property_count_u32_elems() #
int Count the number of u32 elements in a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a property in a device node and count the number of u32 elements in it.
Return
The number of elements on success, -EINVAL if the property does not exist or its length does not match a multiple of u32 and -ENODATA if the property does not have a value.
of_property_count_u64_elems() #
int Count the number of u64 elements in a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a property in a device node and count the number of u64 elements in it.
Return
The number of elements on success, -EINVAL if the property does not exist or its length does not match a multiple of u64 and -ENODATA if the property does not have a value.
of_property_read_string_array() #
int Read an array of strings from a multiple strings property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.const char **out_strs: output array of string pointers.size_t sz: number of array elements to read.
Description
Search for a property in a device tree node and retrieve a list of terminated string values (pointer to data, not a copy) in that property.
Return
If out_strs is NULL, the number of strings in the property is returned.
of_property_count_strings() #
int Find and return the number of strings from a multiple strings property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a property in a device tree node and retrieve the number of null terminated string contain in it.
Return
The number of strings on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EILSEQ if the string is not null-terminated within the length of the property data.
of_property_read_string_index() #
int Find and read a string from a multiple strings property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.int index: index of the string in the list of stringsconst char **output: pointer to null terminated return string, modified only if return value is 0.
Description
Search for a property in a device tree node and retrieve a null terminated string value (pointer to data, not a copy) in the list of strings contained in that property.
The out_string pointer is modified only if a valid string can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EILSEQ if the string is not null-terminated within the length of the property data.
of_property_present() #
bool Test if a property is present in a node
Parameters
const struct device_node *np: device node to search for the property.const char *propname: name of the property to be searched.
Description
Test for a property present in a device node.
Return
true if the property exists false otherwise.
of_property_read_u8_array() #
int Find and read an array of u8 from a property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u8 *out_values: pointer to return value, modified only if return value is 0.size_t sz: number of array elements to read
Description
Search for a property in a device node and read 8-bit value(s) from it.
- dts entry of array should be like:
property = /bits/ 8 <0x50 0x60 0x70>;
The out_values is modified only if a valid u8 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u16_array() #
int Find and read an array of u16 from a property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u16 *out_values: pointer to return value, modified only if return value is 0.size_t sz: number of array elements to read
Description
Search for a property in a device node and read 16-bit value(s) from it.
- dts entry of array should be like:
property = /bits/ 16 <0x5000 0x6000 0x7000>;
The out_values is modified only if a valid u16 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u32_array() #
int Find and read an array of 32 bit integers from a property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 *out_values: pointer to return value, modified only if return value is 0.size_t sz: number of array elements to read
Description
Search for a property in a device node and read 32-bit value(s) from it.
The out_values is modified only if a valid u32 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u64_array() #
int Find and read an array of 64 bit integers from a property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u64 *out_values: pointer to return value, modified only if return value is 0.size_t sz: number of array elements to read
Description
Search for a property in a device node and read 64-bit value(s) from it.
The out_values is modified only if a valid u64 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
struct of_changeset_entry #
Holds a changeset entry
Definition
;
Members
node: list_head for the log listaction: notifier actionnp: pointer to the device node affectedprop: pointer to the property affectedold_prop: hold a pointer to the original property
Description
Every modification of the device tree during a changeset is held in a list of of_changeset_entry structures. That way we can recover from a partial application, or we can revert the changeset
struct of_changeset #
changeset tracker structure
Definition
;
Members
entries: list_head for the changeset entries
Description
changesets are a convenient way to apply bulk changes to the live tree. In case of an error, changes are rolled-back. changesets live on after initial application, and if not destroyed after use, they can be reverted in one single call.
of_device_is_system_power_controller() #
bool Tells if system-power-controller is found for device_node
Parameters
const struct device_node *np: Pointer to the given device_node
Return
true if present false otherwise
of_have_populated_dt() #
bool Has DT been populated by bootloader
Parameters
void: no arguments
Return
True if a DTB has been populated by the bootloader and it isn't the empty builtin one. False otherwise.
of_property_read_bool() #
bool Find a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.
Description
Search for a boolean property in a device node. Usage on non-boolean property types is deprecated.
Return
true if the property exists false otherwise.
of_graph_is_present() #
bool check graph's presence
Parameters
const struct device_node *node: pointer to device_node containing graph port
Return
True if node has a port or ports (with a port) sub-node, false otherwise.
of_property_count_elems_of_size() #
int Count the number of elements in a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.int elem_size: size of the individual element
Description
Search for a property in a device node and count the number of elements of size elem_size in it.
Return
The number of elements on sucess, -EINVAL if the property does not exist or its length does not match a multiple of elem_size and -ENODATA if the property does not have a value.
of_property_read_u8_index() #
int Find and read a u8 from a multi-value property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 index: index of the u8 in the list of valuesu8 *out_value: pointer to return value, modified only if no error.
Description
Search for a property in a device node and read nth 8-bit value from it.
The out_value is modified only if a valid u8 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u16_index() #
int Find and read a u16 from a multi-value property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 index: index of the u16 in the list of valuesu16 *out_value: pointer to return value, modified only if no error.
Description
Search for a property in a device node and read nth 16-bit value from it.
The out_value is modified only if a valid u16 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u32_index() #
int Find and read a u32 from a multi-value property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 index: index of the u32 in the list of valuesu32 *out_value: pointer to return value, modified only if no error.
Description
Search for a property in a device node and read nth 32-bit value from it.
The out_value is modified only if a valid u32 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_u64_index() #
int Find and read a u64 from a multi-value property.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 index: index of the u64 in the list of valuesu64 *out_value: pointer to return value, modified only if no error.
Description
Search for a property in a device node and read nth 64-bit value from it.
The out_value is modified only if a valid u64 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_variable_u8_array() #
int Find and read an array of u8 from a property, with bounds on the minimum and maximum array size.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u8 *out_values: pointer to found values.size_t sz_min: minimum number of array elements to readsize_t sz_max: maximum number of array elements to read, if zero there is no upper limit on the number of elements in the dts entry but only sz_min will be read.
Description
Search for a property in a device node and read 8-bit value(s) from it.
- dts entry of array should be like:
property = /bits/ 8 <0x50 0x60 0x70>;
The out_values is modified only if a valid u8 value can be decoded.
Return
The number of elements read on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data is smaller than sz_min or longer than sz_max.
of_property_read_variable_u16_array() #
int Find and read an array of u16 from a property, with bounds on the minimum and maximum array size.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u16 *out_values: pointer to found values.size_t sz_min: minimum number of array elements to readsize_t sz_max: maximum number of array elements to read, if zero there is no upper limit on the number of elements in the dts entry but only sz_min will be read.
Description
Search for a property in a device node and read 16-bit value(s) from it.
- dts entry of array should be like:
property = /bits/ 16 <0x5000 0x6000 0x7000>;
The out_values is modified only if a valid u16 value can be decoded.
Return
The number of elements read on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data is smaller than sz_min or longer than sz_max.
of_property_read_variable_u32_array() #
int Find and read an array of 32 bit integers from a property, with bounds on the minimum and maximum array size.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u32 *out_values: pointer to return found values.size_t sz_min: minimum number of array elements to readsize_t sz_max: maximum number of array elements to read, if zero there is no upper limit on the number of elements in the dts entry but only sz_min will be read.
Description
Search for a property in a device node and read 32-bit value(s) from it.
The out_values is modified only if a valid u32 value can be decoded.
Return
The number of elements read on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data is smaller than sz_min or longer than sz_max.
of_property_read_u64() #
int Find and read a 64 bit integer from a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u64 *out_value: pointer to return value, modified only if return value is 0.
Description
Search for a property in a device node and read a 64-bit value from it.
The out_value is modified only if a valid u64 value can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data isn't large enough.
of_property_read_variable_u64_array() #
int Find and read an array of 64 bit integers from a property, with bounds on the minimum and maximum array size.
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.u64 *out_values: pointer to found values.size_t sz_min: minimum number of array elements to readsize_t sz_max: maximum number of array elements to read, if zero there is no upper limit on the number of elements in the dts entry but only sz_min will be read.
Description
Search for a property in a device node and read 64-bit value(s) from it.
The out_values is modified only if a valid u64 value can be decoded.
Return
The number of elements read on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EOVERFLOW if the property data is smaller than sz_min or longer than sz_max.
of_property_read_string() #
int Find and read a string from a property
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.const char **out_string: pointer to null terminated return string, modified only if return value is 0.
Description
Search for a property in a device tree node and retrieve a null terminated string value (pointer to data, not a copy).
Note that the empty string "" has length of 1, thus -ENODATA cannot be interpreted as an empty string.
The out_string pointer is modified only if a valid string can be decoded.
Return
0 on success, -EINVAL if the property does not exist, -ENODATA if property does not have a value, and -EILSEQ if the string is not null-terminated within the length of the property data.
of_property_match_string() #
int Find string in a list and return index
Parameters
const struct device_node *np: pointer to the node containing the string list propertyconst char *propname: string list property nameconst char *string: pointer to the string to search for in the string list
Description
Search for an exact match of string in a device node property which is a string of lists.
Return
the index of the first occurrence of the string on success, -EINVAL if the property does not exist, -ENODATA if the property does not have a value, and -EILSEQ if the string is not null-terminated within the length of the property data.
of_property_read_string_helper() #
int Utility helper for parsing string properties
Parameters
const struct device_node *np: device node from which the property value is to be read.const char *propname: name of the property to be searched.const char **out_strs: output array of string pointers.size_t sz: number of array elements to read.int skip: Number of strings to skip over at beginning of list.
Description
Don't call this function directly. It is a utility helper for the of_property_read_string*() family of functions.
of_graph_parse_endpoint() #
int parse common endpoint node properties
Parameters
const struct device_node *node: pointer to endpoint device_nodestruct of_endpoint *endpoint: pointer to the OF endpoint data structure
Description
The caller should hold a reference to node.
of_graph_get_port_by_id() #
struct device_node * get the port matching a given id
Parameters
struct device_node *parent: pointer to the parent device nodeu32 id: id of the port
Return
A 'port' node pointer with refcount incremented. The caller
has to use of_node_put() on it when done.
of_graph_get_next_port() #
struct device_node * get next port node.
Parameters
const struct device_node *parent: pointer to the parent device node, or parent ports nodestruct device_node *prev: previous port node, or NULL to get first
Description
Parent device node can be used as parent whether device node has ports node or not. It will work same as ports@0 node.
Return
A 'port' node pointer with refcount incremented. Refcount of the passed prev node is decremented.
of_graph_get_next_port_endpoint() #
struct device_node * get next endpoint node in port. If it reached to end of the port, it will return NULL.
Parameters
const struct device_node *port: pointer to the target port nodestruct device_node *prev: previous endpoint node, or NULL to get first
Return
An 'endpoint' node pointer with refcount incremented. Refcount of the passed prev node is decremented.
of_graph_get_next_endpoint() #
struct device_node * get next endpoint node
Parameters
const struct device_node *parent: pointer to the parent device nodestruct device_node *prev: previous endpoint node, or NULL to get first
Return
An 'endpoint' node pointer with refcount incremented. Refcount of the passed prev node is decremented.
of_graph_get_endpoint_by_regs() #
struct device_node * get endpoint node of specific identifiers
Parameters
const struct device_node *parent: pointer to the parent device nodeint port_reg: identifier (value of reg property) of the parent port nodeint reg: identifier (value of reg property) of the endpoint node
Return
An 'endpoint' node pointer which is identified by reg and at the same
is the child of a port node identified by port_reg. reg and port_reg are
ignored when they are -1. Use of_node_put() on the pointer when done.
of_graph_get_remote_endpoint() #
struct device_node * get remote endpoint node
Parameters
const struct device_node *node: pointer to a local endpoint device_node
Return
Remote endpoint node associated with remote endpoint node linked
to node. Use of_node_put() on it when done.
of_graph_get_port_parent() #
struct device_node * get port's parent node
Parameters
struct device_node *node: pointer to a local endpoint device_node
Return
device node associated with endpoint node linked
to node. Use of_node_put() on it when done.
of_graph_get_remote_port_parent() #
struct device_node * get remote port's parent node
Parameters
const struct device_node *node: pointer to a local endpoint device_node
Return
Remote device node associated with remote endpoint node linked
to node. Use of_node_put() on it when done.
of_graph_get_remote_port() #
struct device_node * get remote port node
Parameters
const struct device_node *node: pointer to a local endpoint device_node
Return
Remote port node associated with remote endpoint node linked
to node. Use of_node_put() on it when done.
of_graph_get_endpoint_count() #
unsigned int get the number of endpoints in a device node
Parameters
const struct device_node *np: parent device node containing ports and endpoints
Return
count of endpoint of this device node
of_graph_get_port_count() #
unsigned int get the number of port in a device or ports node
Parameters
struct device_node *np: pointer to the device or ports node
Return
count of port of this device or ports node
of_graph_get_remote_node() #
struct device_node * get remote parent device_node for given port/endpoint
Parameters
const struct device_node *node: pointer to parent device_node containing graph port/endpointu32 port: identifier (value of reg property) of the parent port nodeu32 endpoint: identifier (value of reg property) of the endpoint node
Return
Remote device node associated with remote endpoint node linked
to node. Use of_node_put() on it when done.
struct of_endpoint #
the OF graph endpoint data structure
Definition
;
Members
port: identifier (value of reg property) of a port this endpoint belongs toid: identifier (value of reg property) of this endpointlocal_node: pointer to device_node of this endpoint
for_each_endpoint_of_node() #
iterate over every endpoint in a device node
Parameters
parent: parent device node containing ports and endpointschild: loop variable pointing to the current endpoint node
Description
When breaking out of the loop, of_node_put(child) has to be called manually.
for_each_of_graph_port() #
iterate over every port in a device or ports node
Parameters
parent: parent device or ports node containing portchild: loop variable pointing to the current port node
Description
When breaking out of the loop, and continue to use the child, you need to
use return_ptr(child) or no_free_ptr(child) not to call __free() for it.
for_each_of_graph_port_endpoint() #
iterate over every endpoint in a port node
Parameters
parent: parent port nodechild: loop variable pointing to the current endpoint node
Description
When breaking out of the loop, and continue to use the child, you need to
use return_ptr(child) or no_free_ptr(child) not to call __free() for it.
of_translate_dma_region() #
const __be32 * Translate device tree address and size tuple
Parameters
struct device_node *dev: device tree node for which to translateconst __be32 *prop: pointer into array of cellsphys_addr_t *start: return value for the start of the DMA rangesize_t *length: return value for the length of the DMA range
Description
Returns a pointer to the cell immediately following the translated DMA region.
of_property_read_reg() #
int Retrieve the specified "reg" entry index without translating
Parameters
struct device_node *np: device tree node for which to retrieve "reg" fromint idx: "reg" entry index to readu64 *addr: return value for the untranslated addressu64 *size: return value for the entry size
Description
Returns -EINVAL if "reg" is not found. Returns 0 on success with addr and size values filled in.
of_dma_is_coherent() #
bool Check if device is coherent
Parameters
struct device_node *np: device node
Description
It returns true if "dma-coherent" property was found for this device in the DT, or if DMA is coherent by default for OF devices on the current platform and no "dma-noncoherent" property was found for this device.
of_address_to_resource() #
int Translate device tree address and return as resource
Parameters
struct device_node *dev: Caller's Device Nodeint index: Index into the arraystruct resource *r: Pointer to resource array
Description
Returns -EINVAL if the range cannot be converted to resource.
Note that if your address is a PIO address, the conversion will fail if
the physical address can't be internally converted to an IO token with
pci_address_to_pio(), that is because it's either called too early or it
can't be matched to any host bridge IO space
of_iomap() #
void __iomem * Maps the memory mapped IO for a given device_node
Parameters
struct device_node *np: the device whose io range will be mappedint index: index of the io range
Description
Returns a pointer to the mapped memory
irq_of_parse_and_map() #
unsigned int Parse and map an interrupt into linux virq space
Parameters
struct device_node *dev: Device node of the device whose interrupt is to be mappedint index: Index of the interrupt to map
Description
This function is a wrapper that chains of_irq_parse_one() and
irq_create_of_mapping() to make things easier to callers
of_irq_find_parent() #
struct device_node * Given a device node, find its interrupt parent node
Parameters
struct device_node *child: pointer to device node
Return
A pointer to the interrupt parent node with refcount increased or NULL if the interrupt parent could not be determined.
of_irq_parse_raw() #
int Low level interrupt tree parsing
Parameters
const __be32 *addr: address specifier (start of "reg" property of the device) in be32 formatstruct of_phandle_args *out_irq: structure of_phandle_args updated by this function
Description
This function is a low-level interrupt tree walking function. It can be used to do a partial walk with synthesized reg and interrupts properties, for example when resolving PCI interrupts when no device node exist for the parent. It takes an interrupt specifier structure as input, walks the tree looking for any interrupt-map properties, translates the specifier for each map, and then returns the translated map.
Return
0 on success and a negative number on error
Note
refcount of node out_irq->np is increased by 1 on success.
of_irq_parse_one() #
int Resolve an interrupt for a device
Parameters
struct device_node *device: the device whose interrupt is to be resolvedint index: index of the interrupt to resolvestruct of_phandle_args *out_irq: structure of_phandle_args filled by this function
Description
This function resolves an interrupt for a node by walking the interrupt tree, finding which interrupt controller node it is attached to, and returning the interrupt specifier that can be used to retrieve a Linux IRQ number.
Note
refcount of node out_irq->np is increased by 1 on success.
of_irq_to_resource() #
int Decode a node's IRQ and return it as a resource
Parameters
struct device_node *dev: pointer to device tree nodeint index: zero-based index of the irqstruct resource *r: pointer to resource structure to return result into.
of_irq_get() #
int Decode a node's IRQ and return it as a Linux IRQ number
Parameters
struct device_node *dev: pointer to device tree nodeint index: zero-based index of the IRQ
Return
Linux IRQ number on success, or 0 on the IRQ mapping failure, or -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case of any other failure.
of_irq_get_byname() #
int Decode a node's IRQ and return it as a Linux IRQ number
Parameters
struct device_node *dev: pointer to device tree nodeconst char *name: IRQ name
Return
Linux IRQ number on success, or 0 on the IRQ mapping failure, or -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case of any other failure.
of_irq_count() #
int Count the number of IRQs a node uses
Parameters
struct device_node *dev: pointer to device tree node
of_irq_to_resource_table() #
int Fill in resource table with node's IRQ info
Parameters
struct device_node *dev: pointer to device tree nodestruct resource *res: array of resources to fill inint nr_irqs: the number of IRQs (and upper bound for num of res elements)
Return
The size of the filled in table (up to nr_irqs).
of_msi_xlate() #
u32 map a MSI ID and find relevant MSI controller node
Parameters
struct device *dev: device for which the mapping is to be done.struct device_node **msi_np: Pointer to target MSI controller nodeu32 id_in: Device ID.
Description
Walk up the device hierarchy looking for devices with a "msi-map" or "msi-parent" property. If found, apply the mapping to id_in. If msi_np points to a non-NULL device node pointer, only entries targeting that node will be matched; if it points to a NULL value, it will receive the device node of the first matching target phandle, with a reference held.
Return
The mapped MSI id.
of_msi_get_domain() #
struct irq_domain * Use msi-parent to find the relevant MSI domain
Parameters
struct device *dev: device for which the domain is requestedconst struct device_node *np: device node for devenum irq_domain_bus_token token: bus type for this domain
Description
Parse the msi-parent property and returns the corresponding MSI domain.
Return
the MSI domain for this device (or NULL on failure).
of_msi_configure() #
void Set the msi_domain field of a device
Parameters
struct device *dev: device structure to associate with an MSI irq domainconst struct device_node *np: device node for that device
of_fdt_unflatten_tree() #
void * create tree of device_nodes from flat blob
Parameters
const unsigned long *blob: Flat device tree blobstruct device_node *dad: Parent device nodestruct device_node **mynodes: The device tree created by the call
Description
unflattens the device-tree passed by the firmware, creating the tree of struct device_node. It also fills the "name" and "type" pointers of the nodes so the normal device-tree walking functions can be used.
Return
NULL on failure or the memory chunk containing the unflattened device tree on success.
Driver model functions #
of_driver_match_device() #
int Tell if a driver's of_match_table matches a device.
Parameters
struct device *dev: the device structure to match againstconst struct device_driver *drv: the device_driver structure to test
of_match_device() #
const struct of_device_id * Tell if a struct device matches an of_device_id list
Parameters
const struct of_device_id *matches: array of of_device_id match structures to search inconst struct device *dev: the OF device structure to match against
Description
Used by a driver to check whether an platform_device present in the system is in its list of supported devices.
of_dma_configure_id() #
int Setup DMA configuration
Parameters
struct device *dev: Device to apply DMA configurationstruct device_node *np: Pointer to OF node having DMA configurationbool force_dma: Whether device is to be set up byof_dma_configure()even if DMA capability is not explicitly described by firmware.const u32 *id: Optional const pointer value input id
Description
Try to get devices's DMA configuration from DT and update it accordingly.
If platform code needs to use its own special DMA configuration, it can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events to fix up DMA configuration.
of_device_modalias() #
ssize_t Fill buffer with newline terminated modalias string
Parameters
struct device *dev: Calling devicechar *str: Modalias stringssize_t len: Size of str
of_device_uevent() #
void Display OF related uevent information
Parameters
const struct device *dev: Device to display the uevent information forstruct kobj_uevent_env *env: Kernel object's userspace event reference to fill up
of_device_make_bus_id() #
void Use the device node data to assign a unique name
Parameters
struct device *dev: pointer to device structure that is linked to a device tree node
Description
This routine will first try using the translated bus address to derive a unique name. If it cannot, then it will prepend names from parent nodes until a unique name can be derived.
struct of_dev_auxdata #
lookup table entry for device names & platform_data
Definition
;
Members
compatible: compatible value of node to match against nodephys_addr: Start address of registers to match against nodename: Name to assign for matching nodesplatform_data: platform_data to assign for matching nodes
Description
This lookup table allows the caller of of_platform_populate() to override
the names of devices when creating devices from the device tree. The table
should be terminated with an empty entry. It also allows the platform_data
pointer to be set.
The reason for this functionality is that some Linux infrastructure uses the device name to look up a specific device, but the Linux-specific names are not encoded into the device tree, so the kernel needs to provide specific values.
Note
Using an auxdata lookup table should be considered a last resort when converting a platform to use the DT. Normally the automatically generated device name will not matter, and drivers should obtain data from the device node instead of from an anonymous platform_data pointer.
of_find_device_by_node() #
struct platform_device * Find the platform_device associated with a node
Parameters
struct device_node *np: Pointer to device tree node
Description
Takes a reference to the embedded struct device which needs to be dropped after use.
Return
platform_device pointer, or NULL if not found
of_device_alloc() #
struct platform_device * Allocate and initialize an of_device
Parameters
struct device_node *np: device node to assign to deviceconst char *bus_id: Name to assign to the device. May be null to use default name.struct device *parent: Parent device.
of_platform_device_create() #
struct platform_device * Alloc, initialize and register an of_device
Parameters
struct device_node *np: pointer to node to create device forconst char *bus_id: name to assign devicestruct device *parent: Linux device model parent device.
Return
Pointer to created platform device, or NULL if a device was not registered. Unavailable devices will not get registered.
of_platform_bus_probe() #
int Probe the device-tree for platform buses
Parameters
struct device_node *root: parent of the first level to probe or NULL for the root of the treeconst struct of_device_id *matches: match table for bus nodesstruct device *parent: parent to hook devices from, NULL for toplevel
Description
Note that children of the provided root are not instantiated as devices unless the specified root itself matches the bus list and is not NULL.
of_platform_populate() #
int Populate platform_devices from device tree data
Parameters
struct device_node *root: parent of the first level to probe or NULL for the root of the treeconst struct of_device_id *matches: match table, NULL to use the defaultconst struct of_dev_auxdata *lookup: auxdata table for matching id and platform_data with device nodesstruct device *parent: parent to hook devices from, NULL for toplevel
Description
Similar to of_platform_bus_probe(), this function walks the device tree
and creates devices from nodes. It differs in that it follows the modern
convention of requiring all device nodes to have a 'compatible' property,
and it is suitable for creating devices which are children of the root
node (of_platform_bus_probe will only create children of the root which
are selected by the matches argument).
New board support should be using this function instead of
of_platform_bus_probe().
Return
0 on success, < 0 on failure.
of_platform_depopulate() #
void Remove devices populated from device tree
Parameters
struct device *parent: device which children will be removed
Description
Complementary to of_platform_populate(), this function removes children
of the given device (and, recursively, their children) that have been
created from their respective device tree nodes (and only those,
leaving others - eg. manually created - unharmed).
devm_of_platform_populate() #
int Populate platform_devices from device tree data
Parameters
struct device *dev: device that requested to populate from device tree data
Description
Similar to of_platform_populate(), but will automatically call
of_platform_depopulate() when the device is unbound from the bus.
Return
0 on success, < 0 on failure.
devm_of_platform_depopulate() #
void Remove devices populated from device tree
Parameters
struct device *dev: device that requested to depopulate from device tree data
Description
Complementary to devm_of_platform_populate(), this function removes children
of the given device (and, recursively, their children) that have been
created from their respective device tree nodes (and only those,
leaving others - eg. manually created - unharmed).
Overlay and Dynamic DT functions #
of_resolve_phandles() #
int Relocate and resolve overlay against live tree
Parameters
struct device_node *overlay: Pointer to devicetree overlay to relocate and resolve
Description
Modify (relocate) values of local phandles in overlay to a range that does not conflict with the live expanded devicetree. Update references to the local phandles in overlay. Update (resolve) phandle references in overlay that refer to the live expanded devicetree.
Phandle values in the live tree are in the range of
1 .. live_tree_max_phandle(). The range of phandle values in the overlay
also begin with at 1. Adjust the phandle values in the overlay to begin
at live_tree_max_phandle() + 1. Update references to the phandles to
the adjusted phandle values.
The name of each property in the "fixups" node in the overlay matches the name of a symbol (a label) in the live tree. The values of each property in the "fixups" node is a list of the property values in the overlay that need to be updated to contain the phandle reference corresponding to that symbol in the live tree. Update the references in the overlay with the phandle values in the live tree.
overlay must be detached.
Resolving and applying overlay to the live expanded devicetree must be protected by a mechanism to ensure that multiple overlays are processed in a single threaded manner so that multiple overlays will not relocate phandles to overlapping ranges. The mechanism to enforce this is not yet implemented.
Return
0 on success or a negative error value on error.
of_node_get() #
struct device_node * Increment refcount of a node
Parameters
struct device_node *node: Node to inc refcount, NULL is supported to simplify writing of callers
Return
The node with refcount incremented.
of_node_put() #
void Decrement refcount of a node
Parameters
struct device_node *node: Node to dec refcount, NULL is supported to simplify writing of callers
of_detach_node() #
int "Unplug" a node from the device tree.
Parameters
struct device_node *np: Pointer to the caller's Device Node
of_changeset_create_node() #
struct device_node * Dynamically create a device node and attach to a given changeset.
Parameters
struct of_changeset *ocs: Pointer to changesetstruct device_node *parent: Pointer to parent device nodeconst char *full_name: Node full name
Return
Pointer to the created device node or NULL in case of an error.
of_changeset_init() #
void Initialize a changeset for use
Parameters
struct of_changeset *ocs: changeset pointer
Description
Initialize a changeset structure
of_changeset_destroy() #
void Destroy a changeset
Parameters
struct of_changeset *ocs: changeset pointer
Description
Destroys a changeset. Note that if a changeset is applied, its changes to the tree cannot be reverted.
of_changeset_apply() #
int Applies a changeset
Parameters
struct of_changeset *ocs: changeset pointer
Description
Applies a changeset to the live tree. Any side-effects of live tree state changes are applied here on success, like creation/destruction of devices and side-effects like creation of sysfs properties and directories.
Return
0 on success, a negative error value in case of an error. On error the partially applied effects are reverted.
of_changeset_revert() #
int Reverts an applied changeset
Parameters
struct of_changeset *ocs: changeset pointer
Description
Reverts a changeset returning the state of the tree to what it was before the application. Any side-effects like creation/destruction of devices and removal of sysfs properties and directories are applied.
Return
0 on success, a negative error value in case of an error.
of_changeset_action() #
int Add an action to the tail of the changeset list
Parameters
struct of_changeset *ocs: changeset pointerunsigned long action: action to performstruct device_node *np: Pointer to device nodestruct property *prop: Pointer to property
Description
On action being one of:
- OF_RECONFIG_ATTACH_NODE
- OF_RECONFIG_DETACH_NODE,
- OF_RECONFIG_ADD_PROPERTY
- OF_RECONFIG_REMOVE_PROPERTY,
- OF_RECONFIG_UPDATE_PROPERTY
Return
0 on success, a negative error value in case of an error.
of_changeset_add_prop_string() #
int Add a string property to a changeset
Parameters
struct of_changeset *ocs: changeset pointerstruct device_node *np: device node pointerconst char *prop_name: name of the property to be addedconst char *str: pointer to null terminated string
Description
Create a string property and add it to a changeset.
Return
0 on success, a negative error value in case of an error.
of_changeset_add_prop_string_array() #
int Add a string list property to a changeset
Parameters
struct of_changeset *ocs: changeset pointerstruct device_node *np: device node pointerconst char *prop_name: name of the property to be addedconst char * const *str_array: pointer to an array of null terminated stringssize_t sz: number of string array elements
Description
Create a string list property and add it to a changeset.
Return
0 on success, a negative error value in case of an error.
of_changeset_add_prop_u32_array() #
int Add a property of 32 bit integers property to a changeset
Parameters
struct of_changeset *ocs: changeset pointerstruct device_node *np: device node pointerconst char *prop_name: name of the property to be addedconst u32 *array: pointer to an array of 32 bit integerssize_t sz: number of array elements
Description
Create a property of 32 bit integers and add it to a changeset.
Return
0 on success, a negative error value in case of an error.
of_changeset_add_prop_bool() #
int Add a boolean property (i.e. a property without any values) to a changeset.
Parameters
struct of_changeset *ocs: changeset pointerstruct device_node *np: device node pointerconst char *prop_name: name of the property to be added
Description
Create a boolean property and add it to a changeset.
Return
0 on success, a negative error value in case of an error.
of_changeset_update_prop_string() #
int Add a string property update to a changeset
Parameters
struct of_changeset *ocs: changeset pointerstruct device_node *np: device node pointerconst char *prop_name: name of the property to be updatedconst char *str: pointer to null terminated string
Description
Create a string property to be updated and add it to a changeset.
Return
0 on success, a negative error value in case of an error.
of_overlay_notifier_register() #
int Register notifier for overlay operations
Parameters
struct notifier_block *nb: Notifier block to register
Description
Register for notification on overlay operations on device tree nodes. The reported actions defined by of_reconfig_change. The notifier callback furthermore receives a pointer to the affected device tree node.
Note that a notifier callback is not supposed to store pointers to a device tree node or its content beyond OF_OVERLAY_POST_REMOVE corresponding to the respective node it received.
of_overlay_notifier_unregister() #
int Unregister notifier for overlay operations
Parameters
struct notifier_block *nb: Notifier block to unregister
of_overlay_fdt_apply() #
int Create and apply an overlay changeset
Parameters
const void *overlay_fdt: pointer to overlay FDTu32 overlay_fdt_size: number of bytes in overlay_fdtint *ret_ovcs_id: pointer for returning created changeset idconst struct device_node *base: pointer for the target node to apply overlay
Description
Creates and applies an overlay changeset.
See of_overlay_apply() for important behavior information.
On error return, the changeset may be partially applied. This is especially
likely if an OF_OVERLAY_POST_APPLY notifier returns an error. In this case
the caller should call of_overlay_remove() with the value in *ret_ovcs_id.
Return
0 on success, or a negative error number. *ret_ovcs_id is set to
the value of overlay changeset id, which can be passed to of_overlay_remove()
to remove the overlay.
of_overlay_remove() #
int Revert and free an overlay changeset
Parameters
int *ovcs_id: Pointer to overlay changeset id
Description
Removes an overlay if it is permissible. ovcs_id was previously returned
by of_overlay_fdt_apply().
If an error occurred while attempting to revert the overlay changeset, then an attempt is made to re-apply any changeset entry that was reverted. If an error occurs on re-apply then the state of the device tree can not be determined, and any following attempt to apply or remove an overlay changeset will be refused.
- A non-zero return value will not revert the changeset if error is from:
- parameter checks
- overlay changeset pre-remove notifier
- overlay changeset entry revert
If an error is returned by an overlay changeset pre-remove notifier then no further overlay changeset pre-remove notifier will be called.
If more than one notifier returns an error, then the last notifier error to occur is returned.
- A non-zero return value will revert the changeset if error is from:
- overlay changeset entry notifier
- overlay changeset post-remove notifier
If an error is returned by an overlay changeset post-remove notifier then no further overlay changeset post-remove notifier will be called.
Return
0 on success, or a negative error number. *ovcs_id is set to zero after reverting the changeset, even if a subsequent error occurs.
of_overlay_remove_all() #
int Reverts and frees all overlay changesets
Parameters
void: no arguments
Description
Removes all overlays from the system in the correct order.
Return
0 on success, or a negative error number