OF_CHILD(9)
π OF_CHILD(9) π
okay bestie, so this is a page from the Kernel Developer's Manual, and it's literally about walking around the device tree like it's a group chat and you're scrolling through who's related to who π³β¨
πΈ NAME πΈ
OF_child, OF_parent, OF_peer β navigate device tree
β¨ SYNOPSIS β¨
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
phandle_t
OF_child(phandle_t node);
phandle_t
OF_parent(phandle_t node);
phandle_t
OF_peer(phandle_t node);
π¦ DESCRIPTION π¦
so basically you've got a node and you wanna know who's around it in the device tree. these three functions are your little tour guides, no cap π
OF_child()β hands you thephandlevalue of the first child ofnode. If there are literally no children? You get0. bye πOF_parent()β gives you thephandleofnode's parent. But ifnodeis the root node, you get0, because root has no parent, she's the main character πOF_peer()β returns thephandlevalue of the next sibling ofnode. And if there's no sibling node? Yep,0. sad but true π
lowkey the pattern here is: 0 always means "nobody's home". keep that in mind and you're golden β¨
π EXAMPLES π
classic walk-the-children loop, look at her go π«Ά
phandle_t node, child;
...
for (child = OF_child(node); child != 0; child = OF_peer(child) {
...
}
π SEE ALSO π
π AUTHORS π
This manual page was written by Oleksandr Tymoshenko <gonzo@FreeBSD.org>. thank u for ur service, icon π«‘π
and that's the whole vibe bestie β this one's from Debian, dated April 9, 2018, filed under OF_CHILD(9). go forth and traverse that tree, periodt π
β¨π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms