I recently read the LED driver in kernel 2.6.22 and wrote it using platform. The device and driver matching process of platform can be found on the Internet. Through understanding the platform driver framework, we can know that the entrance function of the entire LED driver is the s3c24xx_led_probe function in leds_s3c24xx.c. However, no file_operations struct is defined in the entire file, then there is a question about how to use this driver. After reading a lot of materials, I did not find the answer. I saw a blog post here and I can see how to use it. Http://blog.chinaunix.net/space.php? Uid = 20723576 & Do = Blog & id = 1887064
For the convenience of lookup, turn it over first.
In menuconfig, You must select
Device Driver --->
[*] Led support --->
[*] Led trigger support
In the struct set by the LED, there is a change to def_trigger
Indicates the name of the control LED.
Static struct s3c24xx_led_platdata smdk_pdata_led_blue = {
. Gpio = s3c2410_gpb1,
. Flags = s3c24xx_ledf_tristate,
. Name = "LED-blue ",
. Def_trigger = "NAND-disk ",
}
Indicates that the name of the control led Yunxiao is "NAND-disk"
In linxu/Drivers/MTD/NAND/nand_base.c
Required Bytes: led_trigger_register_simple ("NAND-disk", & nand_led_trigger );
Cancel cancelling rule: led_trigger_unregister_simple (nand_led_trigger );
Control: led_trigger_event (nand_led_trigger, led_full );
Now, as long as you operate on NAND Flash, Zookeeper will be on
In Linux/Drivers/LEDs/leds-s3c24xx.c
Yes
Static void s3c24xx_led_set (struct led_classdev * led_cdev, Enum led_brightness value)
{
Struct s3c24xx_gpio_led * led = to_gpio (led_cdev );
Struct s3c24xx_led_platdata * Pd = led-> pdata;
/* There will be a short delay between setting the output and
* Going from output to input when using tristate .*/
S3c2410_gpio_setpin (Pd-> gpio, (value? 1: 0) ^ (Pd-> flags & s3c24xx_ledf_actlow ));
If (Pd-> flags & s3c24xx_ledf_tristate)
S3c2410_gpio_cfgpin (Pd-> gpio, value? S3c2410_gpio_output: s3c2410_gpio_input );
}
From this example, we can see that the kernel developer re-develops a small framework for the led driver and provides an interface led_trigger_register_simple for upper-layer calls. Further research is required for the specific process.