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?
1 Answer
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
-
Nevertheless one may put some logic in to
unbind
(->remove()
in the driver) callback.– 0andriyCommented Mar 14, 2016 at 7:59 -
Yeah, he explicitly asked about the exit function of the driver that he already has. But indeed, one may still unbind the driver at anytime as long as the .remove callback is present. Commented Mar 14, 2016 at 15:18
printk
logging in your _init and _exit functions? BTW, a quick google search forprintk in module _exit function
shows a few questions on Stack Overflow that might be relevant. This question probably belongs on Stack Overflow, not here.