The modprobe
command makes an init_module
system call to load the LKM into the kernel memory. The init_module
system call invokes the LKM initialization routine immediately after it loads the LKM. As part of its initialization routine, insmod
passes to the address of the subroutine to init_module
.
In the peripheral IP device driver, you already set up init_module
to call a kernel function that registers the subroutines. It calls the kernel’s register_chrdev
subroutine, passing the major and minor number of the devices it intends to drive and the address of its own “open” routine among the arguments. The subroutine register_chrdev
specifies in base kernel tables that when the kernel wants to open that particular device, it should call the open routine in your LKM.