__of_node_dup(9)
πΈ __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 notNULL, it's the node whose properties get duplicated into the shiny new node. if it isNULL... 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'sfull_namefield. 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:
of_node_get(9)of_node_put(9)of_attach_node(9)of_detach_node(9)of_node_release(9)__of_prop_dup(9)of_changeset_create_node(9)of_changeset_init(9)of_changeset_destroy(9)of_changeset_apply(9)of_changeset_revert(9)of_changeset_action(9)of_changeset_add_prop_string(9)of_changeset_add_prop_string_array(9)of_changeset_add_prop_u32_array(9)of_changeset_add_prop_bool(9)of_changeset_update_prop_string(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms