of_get_next_child(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ of_get_next_child (9) ✨

okay bestie, so this is a page out of the Kernel API Manual β€” literally the device tree iteration lore, and honestly? it's giving "small function, huge responsibilities" πŸ’…


πŸŽ€ NAME πŸŽ€

of_get_next_child β€” walk through a node's children, one at a time, no cap


πŸ¦‹ SYNOPSIS πŸ¦‹

struct device_node * of_get_next_child (const struct device_node *node ,
struct device_node *prev );

like yes, that's the whole signature. <italic>node</italic> first, <italic>prev</italic> second, returns a struct device_node *. slay πŸ’–


🌸 ARGUMENTS 🌸

  • node β€” the parent node. the main character of this whole operation πŸ‘‘
  • prev β€” the previous child of the parent node, or NULL to get the first one. so basically "where were we?" or "start over pls" πŸ™ˆ

πŸ’€ RETURN πŸ’€

you get back a node pointer with its refcount incremented β€” like the kernel just handed you a +1 and expects you to be responsible about it 😭 so literally call of_node_put on it when you're done, fr fr.

it returns NULL when prev is the last child (you've reached the end bestie, go home 🏠).

oh and also β€” it decrements the refcount of prev. not me, quietly doing accounting on your behalf. keep that in mind πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

okay this list is long long, so buckle up 🫢 β€” the kernel file is ./drivers/of/base.c:

like, the whole friend group showed up. iykyk 🌈


reminder bestie: refcount goes up, refcount must come down. of_node_put is not optional, it's a lifestyle πŸ’–

and that's the page! brought to you from the source path ./drivers/of, dated October 2026, page of_get_next_child(9) β€” mwah, go iterate responsibly πŸ§šβ€β™€οΈβ­πŸ“

πŸ“¦ where this page comes from