linux内核中常用的一些宏及函数
来源:互联网 发布:云计算技术与应用就业 编辑:程序博客网 时间:2024/06/05 13:30
1 ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) // 该宏可以方便的求出一个数组(x)中有多少数据成员;
2 struct resource
struct resource
static struct resource s3c_lcd_resource[] = {
[0] = {
.start = S3C24XX_PA_LCD,
.end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
.flags = IORESOURCE_MEM, //地址空间
},
[1] = {
.start = IRQ_LCD,
.end = IRQ_LCD,
.flags = IORESOURCE_IRQ, //中断资源
}
};
3 platform(struct platform_driver struct platform_device )
3.1 struct platform_device 相关
struct platform_device s3c_device_rtc = {
.name = "s3c2410-rtc",//需与驱动里面的name要一样
.id = -1,
.num_resources = ARRAY_SIZE(s3c_rtc_resource),
.resource = s3c_rtc_resource,
};
EXPORT_SYMBOL(s3c_device_rtc);
arch/arm/mach-s3c2440/mach-smdk2440.c :
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_rtc, //上面定义
};
static void __init smdk2440_machine_init(void)
{
s3c24xx_fb_set_platdata(&smdk2440_fb_info);
s3c_i2c0_set_platdata(NULL);
platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices)); //添加上面定义的设备
smdk_machine_init();
}
3.2 struct platform_driver
static struct platform_driver rtc_driver =
{
.probe = rtc_probe,
.remove = __devexit_p(rtc_remove
.suspend = rtc_suspend,
.resume = rtc_resume,
.driver =
{
.name = "s3c2410-rtc", // 一定要和平台设备的名称一致,这样才能把二者联系起来
.owner = THIS_MODULE,
},
};
static int __init rtc_init(void)
{
return platform_driver_register(&rtc_driver);
}
static void __exit rtc_exit(void)
{
platform_driver_unregister(&rtc_driver);
}
module_init(rtc_init);
module_exit(rtc_exit);
3.3 设备类的实现(class)
- linux内核中常用的一些宏及函数
- linux内核中常用的一些宏收集
- Linux内核常用的一些宏
- Linux内核中提供的一些字符串转换函数
- Linux内核常用的一些宏的收集
- 【转】Linux内核常用的一些宏的收集
- Linux内核常用的一些宏的收集(精)
- Linux内核常用的一些宏的收集
- Linux内核链表管理的一些常用宏
- linux内核中常用函数API
- linux内核常用的内存申请函数
- linux内核中常用的汇编
- linux 内核中常用的数据结构
- linux内核中常用的汇编
- linux下常用的一些函数
- 一些常用的函数 宏
- Linux常用的一些内核参数(调优)
- Linux常用的一些内核参数(调优)
- 图片
- [C#]温度监控项目的经验
- Reporting Service技巧(一):表格中奇偶行不同颜色的设置
- 守护进程(Daemon)的编写
- 设置IIS的MIME给服务器添加APK文件下载方式
- linux内核中常用的一些宏及函数
- wince下sources\sources.cmn\Makefile.def的相关作用(转载)
- DataTable转换成JSON字符串的函数
- Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)
- ubuntu 解压rar
- 华为时间管理培训
- JSP修改后运行无效果。。。解决
- 清华校长给毕业生的五句话(转载)
- PL/SQL 快捷键设计以及添加快捷键