fdt_for_each...perty_offset(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… fdt_for_each_property_offset β€” a Kernel API Manual moment

okay so bestie, we're in the Kernel API Manual and today's main character is fdt_for_each_property_offset(9). yes that's really the name, yes it's a mouthful, no we're not changing it. πŸŽ€


✨ NAME ✨

fdt_for_each_property_offset β€” literally just iterate over all the properties of a node. that's it. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

fdt_for_each_property_offset (property , fdt , node );

πŸ’– ARGUMENTS πŸ’–

  • property β€” the property offset. it's an int, and it's an lvalue (meaning it gets written to, so pls give it a real home bestie, not a vibe). 🫢
  • fdt β€” the FDT blob, typed const void *. this is the tree itself, the whole thing.
  • node β€” the node offset, an int. which node we're snooping around in. πŸ”

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea: this is not a real function, it's actually a wrapper around a for loop. and you'd use it like this:

fdt_for_each_property_offset(property, fdt, node) { Use property ...  }

and then, because things can go sideways (they always can 😭), you check for errors like:

if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) { Error handling }

ngl the important detail here is that this is implemented as a macro, and property is used as the iterator in the loop. that's the whole reason it has to be an lvalue. no cap. πŸ‘‘

also slay: the node variable can be constant, or even a literal. so you can absolutely just hardcode it and the compiler will not be weird about it. iconic behaviour honestly. ⭐


πŸ’œ SEE ALSO πŸ’œ

this list is long long, so buckle up bestie β€” we're going through the whole friend group. also shoutout to the kernel file ./scripts/dtc/libfdt/libfdt.h where all this lives 🧚


ok that's the whole page bestie, go forth and iterate responsibly πŸ’…βœ¨

and finally, the lil sign-off: this iconic piece of documentation comes from ./scripts/dtc/libfdt and it's dated October 2026. periodt. πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from