1, create the LED drive device files:
(1) Initialize the Cdev with the cdev-init function
(2) Specify the device number
There are two ways to assign a device number: Specify it directly in your code (hard-coded)
Dynamic allocation
(3) using the cdev-add function to add a character device to a character device array in the kernel
(4) Create a struct class using the class-creat Macro
(5) Create a device file using the device-create function
2, led Drive in two ways to control the led
Controlling LEDs with strings
LED via I/O command
3, a complete linux driver mainly consists of internal processing and hardware interaction with two parts.
Inux Drive is also the main processing of these two parts in different platforms; porting in different Linux kernel versions mainly deals with the first part (internal processing); porting on different hardware platforms is primarily about dealing with the second part (interacting with the hardware).
Writing LED drivers