module_platform_driver宏解析
来源:互联网 发布:知豆可以开多少公里 编辑:程序博客网 时间:2024/06/07 06:48
原文地址:http://blog.csdn.net/richu123/article/details/51331081
其中的module_driver在/include/linux/device.h中定义,如下:
由上述定义可知,module_platform_driver()宏的作用就是定义指定名称的平台设备驱动注册函数和平台设备驱动注销函数,并且在函数体内分别通过platform_driver_register()函数和platform_driver_unregister()函数注册和注销该平台设备驱动。
该函数实际是一个宏,它在include/linux/platform_device.h中定义如下:
- /* module_platform_driver() - Helper macro for drivers that don’t do
- * anything special in module init/exit. This eliminates a lot of
- * boilerplate. Each module may only use this macro once, and
- * calling it replaces module_init() and module_exit()
- */
- #define module_platform_driver(__platform_driver) \
- module_driver(__platform_driver, platform_driver_register, \
- platform_driver_unregister)
其中的module_driver在/include/linux/device.h中定义,如下:
- /**
- * module_driver() - Helper macro for drivers that don’t do anything
- * special in module init/exit. This eliminates a lot of boilerplate.
- * Each module may only use this macro once, and calling it replaces
- * module_init() and module_exit().
- *
- * @__driver: driver name
- * @__register: register function for this driver type
- * @__unregister: unregister function for this driver type
- * @…: Additional arguments to be passed to __register and __unregister.
- *
- * Use this macro to construct bus specific macros for registering
- * drivers, and do not use it on its own.
- */
- #define module_driver(__driver, __register, __unregister, …) \
- static int __init __driver##_init(void) \
- { \
- return __register(&(__driver) , ##__VA_ARGS__); \
- } \
- module_init(__driver##_init); \
- static void __exit __driver##_exit(void) \
- { \
- __unregister(&(__driver) , ##__VA_ARGS__); \
- } \
- module_exit(__driver##_exit);
module_platform_driver(xxx);
最终展开后就是如下形式:
static int __init xxx_init(void)
{
return platform_driver_register(&xxx);
}
module_init(xxx_init);
static void __exit xxx_init(void)
{
return platform_driver_unregister(&xxx);
}
module_exit(xxx_exit);
{
return platform_driver_register(&xxx);
}
module_init(xxx_init);
static void __exit xxx_init(void)
{
return platform_driver_unregister(&xxx);
}
module_exit(xxx_exit);
由上述定义可知,module_platform_driver()宏的作用就是定义指定名称的平台设备驱动注册函数和平台设备驱动注销函数,并且在函数体内分别通过platform_driver_register()函数和platform_driver_unregister()函数注册和注销该平台设备驱动。
阅读全文
0 0
- module_platform_driver宏解析
- module_platform_driver宏解析
- module_platform_driver宏解析
- module_platform_driver宏解析
- module_platform_driver()宏
- module_platform_driver(), module_i2c_driver
- 函数module_platform_driver()
- module_platform_driver的作用
- Linux驱动:module_platform_driver
- 【平台设备驱动】中module_platform_driver的定义和使用
- #pragma宏解析
- container_of()宏的解析
- container_of宏定义 解析
- container_of()宏解析
- 预处理 ----解析宏开关
- offsetof宏解析
- QObject宏的解析
- offsetof宏解析
- zookeeper简介
- oracle之 oracle database vault(数据库保险库)
- 常见网站CSS初始化
- T对象转换成map对象/List对象 * 或者map对象/List对象转换为T对象
- HDU 2894 DeBruijin (欧拉回路)
- module_platform_driver宏解析
- Java设计模式----适配器模式
- 关于Collection----ArrayList部分使用方法
- Paxos算法
- 安装tensorflow0.11方法
- 亚马逊Alexa Skill介绍
- 安装MySQL遇到的问题
- 数据结构-单链表按值删除
- Pom.xml详解