---
name: "OF_finddevice"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/OF_finddevice"
---

# OF\_finddevice(9)

find node in device tree

## NAME

**OF\_finddevice** – find 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 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) {
        ...
    }
```

## SEE ALSO

[OF\_child(9)](/OF_child/9.md), [OF\_parent(9)](/OF_parent/9.md), [OF\_peer(9)](/OF_peer/9.md)

## AUTHORS

This manual page was written by Oleksandr Tymoshenko ⟨*gonzo@FreeBSD.org*⟩.

## 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.
