of_get_compatible_child(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 of_get_compatible_child(9) β€” Kernel API Manual 🌸

okay bestie, sit down, we're learning about of_get_compatible_child today and honestly? it's a little cutie. this is from the Kernel API Manual, and it's gonna take like two minutes, you got this πŸ’–


✨ NAME ✨

of_get_compatible_child β€” find a compatible child node πŸŽ€


✨ SYNOPSIS ✨

struct device_node * of_get_compatible_child (const struct device_node
*parent , const char *compatible );

like, look at that signature. struct device_node * out front, two args in the back. we love a return type that's a pointer, ngl πŸ’…


✨ ARGUMENTS ✨

  • parent β€” the parent node 🫢 that's it, that's the whole thing, it's the node you're looking inside of.
  • compatible β€” the compatible string ⭐ this is the thing you're hunting for, bestie.

✨ DESCRIPTION ✨

so here's the vibe: you look up the child node whose compatible property contains the given compatible string. that's the whole quest. no cap. πŸ”₯

like, you hand it a parent, you hand it a string, and it goes digging through the children looking for one whose compatible property has your string in it. iconic behavior honestly πŸ¦‹


✨ RETURN ✨

you get back a node pointer with its refcount incremented πŸ‘‘ β€” and bestie, listen to me β€” when you're done with it, you must call of_node_put on it. that's not optional, that's not a suggestion, that's the rule πŸ’€

or you get NULL if it's not found. sad but valid πŸ™ˆ

⚠️ the refcount is incremented on the way out, so if you forget of_node_put you're leaking. do not be that girlie. πŸ’…

✨ SEE ALSO ✨

the kernel file ./drivers/of/base.c is where this lives, and here's the whole friend group 🧚:

that's a lot of siblings but we love them all equally 🌈


and that's the page, bestie!! πŸŽ€ it lives over in ./drivers/of and this particular glow-up is dated October 2026 β€” slay, see you in the next one πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from