I'm running unregister_chrdev(major, "mod_name"); but I can still the the device in ls -l /dev/.
What am I doing wrong?
I'm running unregister_chrdev(major, "mod_name"); but I can still the the device in ls -l /dev/.
What am I doing wrong?
register_chrdev(9) and unregister_chrdev(9) do not actually create or remove files in /dev directory. You should create them beforehand by a load script. Deletion is the same, you should delete them manually.
See scull example, scull_load creates a char file (with the same major number as your module) after loading the module with insmod. scull_unload is similar, removes files under /dev after unloading with rmmod.
As @myaut suggested, this can also be done with device_create, but this is a GPL-only function and if your module is not licensed under GPL, you will have to create the files manually.