cdev_set_parent(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– cdev_set_parent(9) πŸ’–

okay so hii bestie, welcome to the Kernel API Manual ✨ today’s main character is cdev_set_parent, and it’s lowkey one of those tiny functions with big β€œplease don’t free my parent too early” energy. no cap πŸŽ€


🌸 NAME 🌸

cdev_set_parent β€” set the parent kobject for a char device πŸ¦‹

✨ SYNOPSIS ✨

void cdev_set_parent (struct cdev *p , struct kobject *kobj );

🫢 ARGUMENTS 🫢

  • p β€” the cdev structure πŸ‘‘
  • kobj β€” the kobject to take a reference to 🌟

πŸ’… DESCRIPTION πŸ’…

So cdev_set_parent sets a parent kobject, and that parent gets referenced appropriately β€” meaning the parent is not freed before the cdev. periodt πŸ’– that’s the whole safety vibe: the parent stays properly referenced so it doesn’t dip out before the cdev is done with it.

bestie, this should be called before cdev_add. like, before-before. the ordering is literally the moment πŸ’€βœ¨

🌈 SEE ALSO 🌈

Kernel file ./fs/char_dev.c is the spot, and the whole squad is right here:

iykyk β€” read the squad, stay cozy in the kernel πŸ§šπŸ’œ


mwah πŸ’‹ this lil page comes from source/version ./fs, and it’s dated October 2026 β€” catch you in the kernel, bestie πŸ«ΆπŸ’–

πŸ“¦ where this page comes from