The main steps of the simple led program are as follows:
First: Create LED-driven device files
1. Initialize the Cdev with the Cdev_init function
2. Specify the device number
3. Use the Cdev_add function to add a character device to a character device array in the kernel
4. Create Struct_class using Class_create macros
5. Create a device file using the Device_create function
II: Uninstall the LED drive device files
Three: Set register and initialize led driver
Four: Control LED (and so-called code writing--LINUXC language)
An example of an implementation method is as follows:
In a hybrid device driver, you need to populate the file_operations structure, and then set the Miscdevices value for each field and register it with the kernel. The detailed process is as follows:
1. Writing the IOCTL interface function
2. Fill in the file_operations structure, mainly by registering the IOCTL function
3. Fill the miscdevice structure, mainly the secondary device number, FoPs, and device name.
4. Write the initialization code that you want to provide to the Module_init macro, set the LED port to output, and register it with the kernel.
5. Write the logoff code to be provided to the Module_exit macro, primarily to unregister the Miscdevice device registered with the kernel in the initialization
The LED driver includes the necessary parts of the Linux drive. A complete Linux drive consists mainly of internal processing and interaction with hardware. The internal processing mainly refers to the Linux driver loading, unloading, device file-related action processing, and business logic.
Address: http://www.cnblogs.com/zpm123123
Seventh chapter LED will blink for me: Control the Light emitting diode