__of_node_dup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 __of_node_dup(9) β€” the Kernel API Manual, bestie edition 🌸

okay so this is page __of_node_dup(9) from the Kernel API Manual, and she is literally the moment you need when you're out here building device nodes at runtime. sit down, grab a strawberry πŸ“, we're learning.


✨ NAME ✨

__of_node_dup β€” duplicate a device node, or spawn a brand-new empty one, dynamically. like, at runtime. on the fly. main character behavior only πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

struct device_node * __of_node_dup (const struct device_node *np , const
       char *full_name );

that's the whole signature, no cap. returns a struct device_node *, takes two args, that's it, that's the vibe.


πŸŽ€ ARGUMENTS πŸŽ€

  • np β€” if this is not NULL, it's the node whose properties get duplicated into the shiny new node. if it is NULL... well then babe you're just making an empty one, and that's valid too 🫢
  • full_name β€” a string value that gets duplicated right into the new node's full_name field. it's giving "name tag at the party" energy.

πŸ’– DESCRIPTION πŸ’–

so here's what's happening: this function creates a device tree node, and optionally it duplicates the properties of another node into it. you get to choose β€” pass a real node in np and she copies, or don't and she stays fresh and empty.

the node data are dynamically allocated, and every one of the node's flags gets the OF_DYNAMIC & OF_DETACHED bits set. both of them. set. periodt. πŸ”₯


🌈 RETURN 🌈

you get back the newly allocated node β€” yay! πŸŽ‰

or you get NULL on an out of memory error. 😭 that's the tradeoff bestie.

⚠️ okay so this part is important, do not skip it: when you're done with the node, use of_node_put on it to free the memory that was allocated for it. like, that's not optional. that's the whole cleanup arc. do not ghost your node.

πŸ‘‘ SEE ALSO πŸ‘‘

the kernel file lives at ./drivers/of/dynamic.c, and these are the sibling icons you should also go read, fr fr:

that's seventeen of them, yes I counted, and yes they're all (9) sections, iykyk πŸ’€


mwah πŸ’œ that's the page!! this one came from the ./drivers/of section, dated October 2026 β€” so like, future energy. stay slay, free your nodes, and I'll see you in the next man page πŸ§šβ€β™€οΈβœ¨

πŸ“¦ where this page comes from