OF_FINDDEVICE(9) FreeBSD Kernel Developer's Manual OF_FINDDEVICE(9)

NAME

OF_finddevicefind node in device tree

SYNOPSIS

#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
phandle_t
OF_finddevice(const char *path);

DESCRIPTION

OF_finddevice() returns phandle for the node specified by the path. -1 if the path cannot be found in the tree.

CAVEATS

Return value should be checked only using equality operators (==, !=) and not relational comparison ( <, > ). There is a discrepancy between IEEE 1275 standard and FreeBSD internal representation of phandle: IEEE 1275 requires return value of this function to be -1 if path is not found but phandle_t is unsigned type, so it cannot be relationally compared with -1 or 0, this comparison is always true or always false.

EXAMPLES

    phandle_t root, i2c; 
 
    root = OF_finddevice("/"); 
    i2c = OF_finddevice("/soc/axi/i2c@a0e0000"); 
    if (i2c != -1) { 
        ... 
    }

SEE ALSO

OF_child(9) OF_parent(9) OF_peer(9)

AUTHORS

This manual page was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>.
February 25, 2018 FreeBSD 12.0-CURRENT