cdev_del
takes a pointer, ensure that your my_cdev is a pointer.void cdev_del(struct cdev *);
It is
cdev_del
, first andunregister_chrdev later
, it seems you have done it the other way, usecdev_del
first and thenunregister_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 useregister_chrdev
for registeringOR
"
cdev_init
/cdev_add
afterregister_chrdev_region
" should be used in conjunction with "cdev_del
beforeunregister_chrdev_region
"
Why device exist in /proc/devices evethough module is unloaded
-
01-07-2022 - |
题
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.
解决方案
其他提示
struct cdev has an owner field that should be set to THIS_MODULE. Make sure it is set
不隶属于 StackOverflow