cdev_set_parent(9)
π 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β thecdevstructure πkobjβ thekobjectto 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:
register_chrdev_region(9)alloc_chrdev_region(9)__register_chrdev(9)unregister_chrdev_region(9)__unregister_chrdev(9)cdev_add(9)cdev_device_add(9)cdev_device_del(9)cdev_del(9)cdev_alloc(9)cdev_init(9)
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
- 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