OF_finddevice(9)

OF_finddevice9

Find node in device tree

Usage

#include <dev/ofw/ofw_bus.h>

#include <dev/ofw/ofw_bus_subr.h>

phandle_t

OF_finddevice(const char *path);

Overview

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

Examples

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

Caveats

The return value should only be checked with equality operators (equal to, not equal to) and not relational comparison (less than, greater than ). There is a discrepancy between IEEE 1275 standard and FreeBSD's internal representation of a phandle: IEEE 1275 requires the return value of this function to be -1 if the path is not found. But phandle_t is an unsigned type, so it cannot be relationally compared with -1 or 0, this comparison is always true or always false.

Releases

20 releases since FreeBSD 12.0-RELEASE; the text changed 6 times.

  1. 12.0
  2. 12.1
  3. 12.2
  4. 12.3
  5. 12.4
  6. 13.0–13.2
  7. 13.3–16.0

Authors

This manual page was written by Oleksandr Tymoshenko ⟨[email protected]⟩.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.