pub unsafe extern "C" fn fdt_node_offset_by_compatible(
fdt: *const c_void,
startoffset: c_int,
compatible: *const c_char,
) -> c_intExpand description
fdt_node_offset_by_compatible - find nodes with a given ‘compatible’ value @fdt: pointer to the device tree blob @startoffset: only find nodes after this offset @compatible: ‘compatible’ string to match against
fdt_node_offset_by_compatible() returns the offset of the first node after startoffset, which has a ‘compatible’ property which lists the given compatible string; or if startoffset is -1, the very first such node in the tree.
To iterate through all nodes matching the criterion, the following idiom can be used: offset = fdt_node_offset_by_compatible(fdt, -1, compatible); while (offset != -FDT_ERR_NOTFOUND) { // other code here offset = fdt_node_offset_by_compatible(fdt, offset, compatible); }
Note the -1 in the first call to the function, if 0 is used here instead, the function will never locate the root node, even if it matches the criterion.
returns: structure block offset of the located node (>= 0, >startoffset), on success -FDT_ERR_NOTFOUND, no node matching the criterion exists in the tree after startoffset -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag -FDT_ERR_BADMAGIC, -FDT_ERR_BADVERSION, -FDT_ERR_BADSTATE, -FDT_ERR_BADSTRUCTURE, standard meanings