I wrote a simple device driver that makes device file using class_create() and device_create() function. But then in the exit function of my driver, I destroyed the class first and then the driver, i.e. I called class_destroy() first and then device_destroy(). Due to this in kernel logs I saw some error messages and didn't see the output message that I had put in my exit function.
The driver was also not removed stating that it is still in use.
I want to know:
I think I made a mistake by freeing the class first and then removing the device, so error messages were appropriate. But now I cannot remove my driver using
rmmod. Is there any way to remove the driver without rebooting the system?I used
lsmodto check which service is using my driver. But instead of showing "used by" count as1, it is showing-1. What can be the reason for this behaviour?