Linux kernel modules are specially made to be pieces of kernel that can be loaded and unloaded dynamically, while the kernel is running. These appear as object files (modname.o) and are loaded with the command insmod modname.o [arguments]. This operation runs the initialization of the device(s) and gives a major number to the device driver. This one can be found in the /proc/devices file. The command can receive many arguments specific to the module.
After being loaded, the device driver module must be associated with devices files which will be used by user programs. This is made with the command : mknod devname c major minor.
For the ICV150 device driver, all the work is done in one time by the ICV150_load shell script.
As the ICV150 device driver use a probe call to insure that a board is really responding at the specified address(es), the probe module which contains the probe function must be installed first on system. This one appear as a probe.o object file and can be installed with the insmod -f probe.o command.
One optional parameter can be specified when you load the ICV150 device driver with the ICV150_load script or with the insmod command. The loading command will looks like :
./ICV150_load io_adr=adr0,adr1,adr2,adr3
As the ICV150 device driver can handle up to 4 ICV150 boards at the same time and the ICV150 board(s) do(es) not always have the same address, user can specify board(s) address by adding io_adr=adr0,adr1,... at the end of the loading command. Only the 24 most significant bits of the board's address must be specified in io_adr and these must be presented in a hex format (e.g. : io_adr=0xFF7C04,0xFF7C05 for two ICV150 boards with base addresses 0xFF7C0400 and 0xFF7C0500). In case of no io_adr parameter, only one board with the default address IO_BOARD_ADR (specified in the ICV150.h header file) will try to be loaded. To see which I/O space is already use by devices you can look at the /proc/ioports file.
Error can appear during the module loading. This error may be caused by invalid loading parameters or by the fact that module is already running on system.
A probe function call insures that a board is really responding at the specified address(es) and avoid system crash if not. An error message will appear on the kernel log file if a bus error occurs.
In case of error, you should check if the module is not already running and if all the required resources are free (see the Special files section). You can also use the dmesg command to see debug or error messages (see the Debug options section).
As you can dynamically load your kernel module, you can also unload it when you want using the command rmmod modname. You also have to remove the devices files that you made with ICV150_load.
For the ICV150 device driver, all the work is done by the ICV150_unload shell script.
Nevertheless, the module will be unloaded only if all the processes/threads have been closed before. This is done with the driver's release() function call which is called by the generic close() function. Finally, the call may look like close(FD). If some processes/threads are still using the device driver when you try to unload it, the kernel will display a 'busy device or resource' message on console.