Differences in driver development using platform and file_operations

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.