fdt_node_of...y_compatible(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– fdt_node_offset_by_compatible πŸ’–

okay so bestie, welcome to the Kernel API Manual ✨ β€” this one's short, sweet, and honestly iconic. The page header calls it fdt_node_of...y_compatible(9) (yeah they truncated it, the real star is fdt_node_offset_by_compatible), and we're about to find nodes by their vibes. πŸŽ€


🌸 NAME 🌸

fdt_node_offset_by_compatible β€” find nodes with a given 'compatible' value πŸ¦‹


✨ SYNOPSIS ✨

int fdt_node_offset_by_compatible (const void *fdt , int startoffset ,
       const char *compatible );

🫢 ARGUMENTS 🫢

  • fdt β€” pointer to the device tree blob 🌈 (yes, the whole tree, no cap)
  • startoffset β€” only find nodes after this offset πŸ‘€ like, don't look backward bestie
  • compatible β€” the compatible string we're shopping for πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

So fdt_node_offset_by_compatible returns the offset of the first node after startoffset that has a 'compatible' property listing the given compatible string. ✨ And if startoffset is -1, it gives you the very first such node in the whole tree. Like a fresh start, main character energy.

To iterate through all nodes matching the criterion, the following idiom can be used β€” literally just screenshot this:

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); }
⚠️ bestie listen β€” 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. 😭 Not a vibe. Use -1. periodt.

πŸ”₯ RETURN πŸ”₯

  • structure block offset of the located node (>= 0, >startoffset), on success πŸŽ‰ slay
  • -FDT_ERR_NOTFOUND β€” no node matching the criterion exists in the tree after startoffset πŸ’€ (it's not you, it's the tree)
  • -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 🧚 (iykyk)

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./scripts/dtc/libfdt/libfdt.h β€” and honestly, the whole fdt squad showed up. Obsessed. πŸ’–


that's the whole page, bestie β€” go find ur nodes πŸ’…βœ¨

πŸ¦‹ cute sign-off time: this lil masterpiece lives in ./scripts/dtc/libfdt, dated October 2026, and it's filed under fdt_node_of...y_compatible(9) in the Kernel API Manual. mwah πŸ’‹ πŸŽ€

πŸ“¦ where this page comes from