Adding a Driver to the Kernel Source
Occassionally you may need to rebuild your kernel with a driver which isn’t part of the kernel source you have. This is a general guideline to the steps you will need to carry out. Specific details are dependent on the type of driver. Mention is made of editing various files and inserting extra lines. The position of these lines will depend on the driver. Normally a driver will come with instructions on the exact lines to enter and where. If it doesn’t , you will need to experiment, position the entries near entries for similiar drivers.
In this example we are adding the fictious driver “mydriver” which is a SCSI driver. You will need to adapt these guidelines to the type of driver you have.
To make the driver appear as an option in “make config”, “make menuconfig” or “make xconfig , edit /usr/src/linux/drivers/scsi/Config.in adding the line
dep_tristate ‘My SCSI river’ CONFIG_SCSI_MY_DRIVER $CONFIG_SCSI
Copy the source into place, cp mydriver.c /usr/src/linux/drivers/scsi and cp mydriver.h /usr/src/linux/drivers/scsi
Edit /usr/src/linux/drivers/scsi/Makefile adding the following:
ifeq ($(CONFIG_SCSI_MY_DRIVER),y) L_OBJS += mydriver.o else ifeq ($(CONFIG_SCSI_MY_DRIVER),m) M_OBJS += mydriver.o endif endif
mydriver.o: mydriver.h mydriver.c $(CC) $(CFLAGS) -c mydriver.c -o mydriver.o
- Edit hosts.c adding the following:
#ifdef CONFIG_SCSI_MY_DRIVER #include "mydriver.h" #endif
#ifdef CONFIG_SCSI_MY_DRIVER MYDRIVER_LINUX_TEMPLATE #endif
You are now ready to rebuild the kernel