删除设备创建()、类创建()和 alloc chrdev 区域()创建的文件

After creating a character device driver using alloc_chrdev_region(), cdev_init(), cdev_add(), class_create() and device_create() I am unable to successfully clean all the entries made by the functions above in the module_exit(). When I use rmmod it just says "Killed". When I check the /proc/devices/, /sys/class/ and /dev/ directories my created files are still present. How can I make a clean exit of my module? The code I am using for exit:

static void char_exit(void)
{
    printk(KERN_ALERT "leaving the kernel.");
    cdev_del(my_chardev);

    device_destroy(myclass,first);

    class_destroy(myclass);

    unregister_chrdev_region(first,1);
}

For some reason it's not working.

转载于:https://stackoverflow.com/questions/53058991/removing-files-created-by-device-create-class-create-and-alloc-chrdev-regio

https://baike.baidu.com/item/alloc_chrdev_region/867009