The following example describes how to add a device driver. Block devices and network devices can be processed accordingly.
1. Put the original file in the linux-2.4.x/driver/Char/; in this example, the file name is xyz. c
2. the device driver's original file must include such a function:
Void xyz_init (void) {register (254, 'xyz', & xyz_fops)} This function completes registration. It will be called in linux-2.4.x/driver/MEM. C.
This function can also be written as follows:
Void _ init xyz_init (void) {register (254, 'xyz', & xyz_fops)} does not have to call it in linux-2.4.x/driver/MEM. c
3. Modify the linux-2.4.x/driver/Char/makefile to add a row at the appropriate position:
OBJ _ $ (config_xyz) + = xyz. o
4. Modify linux-2.4.x/driver/Char/config. In and add a line:
Bool 'xyz hahahahaha' config_xyz
It is easy to select when make menuconfig
5. Modify linux-2.4.x/driver/Char/MEM. c
Add:
# Ifdef config_xyz
Extern void xyz_init (void );
# Endif
Add the following in the chr_dev_init () function:
# Ifdef config_xyz
Xyz_init ();
# Endif
6. Modify the vendor/Samsung/4510b/makefile to create a device node;
Add the following content to the device section between 12-35 and 12-35:
Xzy, C, 254,0
7. Make menuconfig select XYZ Hahahaha,
Compile and download. After startup, you will see that the character device in/proc/devices has one more XYZ 254