关于使用platform和file_operations开发驱动的不同
来源:互联网 发布:linux奶瓶破解教程 编辑:程序博客网 时间:2024/05/11 18:14
最近在看2.6.22内核中自带的led驱动,使用platform的方式写的,platform的设备和驱动匹配的过程可以在网上找到资料。通过对platform驱动框架的了解能够知道整个led的驱动的入口函数是leds_s3c24xx.c中的s3c24xx_led_probe函数,可是翻遍了整个文件都没有看到有定义file_operations结构体,那么就产生了如何使用这个驱动的疑问。翻了很多资料都没有找到答案,在这个地方看到了一个博文,可以看到使用方法。http://blog.chinaunix.net/space.php?uid=20723576&do=blog&id=1887064
为了翻查方便,先转过来。
在 menuconfig 裡必須選取
Device Driver --->
[*] LED Support --->
[*] LED Trigger support
在 LED 設定的 struct 中,有一個變數為 def_trigger
表示控制 led 的名稱
static struct s3c24xx_led_platdata smdk_pdata_led_blue = {
.gpio = S3C2410_GPB1,
.flags = S3C24XX_LEDF_TRISTATE,
.name = "led-blue",
.def_trigger = "nand-disk",
}
表示控制 LED 藍燈的名稱是 "nand-disk"
在 linxu/drivers/mtd/nand/nand_base.c
註冊: led_trigger_register_simple("nand-disk", &nand_led_trigger);
取消註冊: led_trigger_unregister_simple(nand_led_trigger);
控制: led_trigger_event(nand_led_trigger, LED_FULL);
現在 只要對 nand flash 操作,藍燈就會亮
在 linux/drivers/leds/leds-s3c24xx.c 中
會呼叫
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);
}
从这个例子大概可以看出来,内核开发者为led的驱动重新开发了一个小框架,提供了一个接口led_trigger_register_simple给上层调用。具体的过程还需要进一步研究。
- 关于使用platform和file_operations开发驱动的不同
- 关于使用platform和file_operations开发驱动的不同
- 驱动该如何入门 关于file_operations和Linux设备模型
- linux驱动开发--字符设备:简单的file_operations示例
- 基于platform简单驱动,probe函数中实现file_operations
- 关于platform设备驱动框架的总结
- 【驱动开发】file_operations ---linux 2.6.30
- 【Linux开发】linux设备驱动归纳总结(九):1.platform总线的设备和驱动
- 对关于字符驱动的一些重要数据结构(file_operations, file, inode, cdev)的理解
- platform设备和驱动的注册(1)
- platform设备和驱动的注册(2)
- platform设备和驱动的注册(3)
- platform设备和驱动的注册机制
- platform设备和驱动
- 设备树在platform设备驱动开发中的使用解析
- Linux简单设备驱动(2): file_operations的write、read、ioctl驱动及Android应用层开发验证
- linux的platform驱动
- linux的platform驱动
- ExtJs复选框树,可实现节点选中自动选中父节点子节点(权限树)
- Android官方文档在WebView中构建Web Apps
- Google 用户体验【用户体验】
- Android官方文档之Web Apps调试
- Android官方文档之Web Apps最佳实践
- 关于使用platform和file_operations开发驱动的不同
- Appcelerator收购Cocoafish,旨在为Titanium平台提供即时移动云服务
- #HTML5 Web App项目秀#国内首款大型HTML5页游《黎明帝国》开发背后
- 实用PHP会员权限控制实现原理分析 .
- 【第一章】C#的进化史——C#1.0,2.0,3.0区别比较(三)——查询集合
- C# 讀取Excel、xlsx文件Excel2007
- Java朝花夕拾の实现Comparable接口
- Shell 学习(五)---stty、[[]]、(()) 等
- 开发安卓系统Android和码输入法软件的全过程(二)