Search code examples
linux-kerneldrivers

How to trigger kernel driver _exit function


I'm testing a driver that I've built into the kernel and would like to verify that my DRIVER_exit command functions as expected. The DRIVER_init command executes automatically during boot, I assume the exit command does the same on shutdown. When testing the driver as a module I utilized insmod and rmmod to execute _init and _exit functions. Is there any command to trigger the exit function prematurely similar to rmmod? Alternatively is there a system log I can look at to see how my last shutdown sequence went?


Solution

  • If your driver is compiled statically in the kernel, it is not possible to call the exit function of your module because it is will be excluded from the kernel at linking time. Have a look at the __exit and __exitused definitions in include/linux/init.h