Knowing how to add custom code to the kernel is useful but, when we have to write a new driver, it can be more useful writing our code as a kernel module. In fact, by using a module, we can easily modify kernel code and then test it without rebooting the system every time! We simply have to remove and then reinsert the module (after the necessary modifications) in order to test the new version of our code.
In this recipe, we'll take a look at how kernel modules can get compiled even on a directory outside the kernel tree.