Reputation: 5349
I am writing a simple charcter driver scull based on ldd. For my sample character driver, evethough module is unloaded device with major number exist in /proc/devices. How to remove that?
My module exit function has
void scull_exit(void)
{
unregister_chrdev(Major, "scull1");
cdev_del(my_cdev);
printk(KERN_ALERT "Good Bye\n");
}
I could see the old device with its major number when I load new module after unloading the same.
Upvotes: 2
Views: 1542
Reputation: 1
struct cdev has an owner field that should be set to THIS_MODULE. Make sure it is set
Upvotes: 0
Reputation: 1591
cdev_del
takes a pointer, ensure that your my_cdev is a
pointer.
void cdev_del(struct cdev *);
It is cdev_del
, first and unregister_chrdev later
, it seems you
have done it the other way, use cdev_del
first and then unregister_chrdev_region
You have mixed up old notation of unregister_chrdev and new notation of cdev_del.
either unregister_chrdev
should be used when you use register_chrdev
for registering
OR
"cdev_init
/cdev_add
after register_chrdev_region
" should be used in conjunction with "cdev_del
before unregister_chrdev_region
"
Upvotes: 3