linux设备模型(四 platform )
来源:互联网 发布:软件编程成果展板 编辑:程序博客网 时间:2024/06/05 01:53
(1)提高程序可移植性
(2)
#include <linux/device.h>
#include <linux/module.h>#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/platform_device.h>
MODULE_AUTHOR("David Xie");
MODULE_LICENSE("Dual BSD/GPL");
static struct platform_device *my_device;
static int __init my_device_init(void)
{
int ret = 0;
/* 分配结构 */
my_device = platform_device_alloc("my_dev", -1);
/*注册设备*/
ret = platform_device_add(my_device);
/*注册失败,释放相关内存*/
if (ret)
platform_device_put(my_device);
return ret;
}
static void my_device_exit(void)
{
platform_device_unregister(my_device);
}
module_init(my_device_init);
module_exit(my_device_exit);
#include <linux/device.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/platform_device.h>
MODULE_AUTHOR("David Xie");
MODULE_LICENSE("Dual BSD/GPL");
static int my_probe(struct device *dev)
{
printk("Driver found device which my driver can handle!\n");
return 0;
}
static int my_remove(struct device *dev)
{
printk("Driver found device unpluged!\n");
return 0;
}
static struct platform_driver my_driver = {
.probe = my_probe,
.remove = my_remove,
.driver = {
.owner = THIS_MODULE,
.name = "my_dev",
},
};
static int __init my_driver_init(void)
{
/*注册平台驱动*/
return platform_driver_register(&my_driver);
}
static void my_driver_exit(void)
{
platform_driver_unregister(&my_driver);
}
module_init(my_driver_init);
module_exit(my_driver_exit);
- linux设备模型(四 platform )
- Linux设备模型(下)之Platform
- Linux设备模型(下)之Platform
- Linux设备模型(三)platform
- Linux设备模型(下)之Platform
- linux设备模型之platform
- Linux 设备模型 --- Platform 驱动程序
- 【linux设备模型】之platform设备驱动
- Linux设备模型之platform总线
- Linux设备驱动模型之platform总线
- Linux设备模型之platform总线
- Linux设备驱动模型之platform总线
- Linux设备模型之platform总线
- Linux设备模型之platform总线
- linux设备模型之platform总线
- linux设备模型之platform总线
- Linux驱动之设备模型(9)-platform
- Linux驱动之设备模型(9)-platform
- 如何用OpenCV自带的adaboost程序训练并检测目标
- SublimeText2 快捷键一览表
- 读《javascript权威指南> 》第五版 第八章 函数
- Android中Activity, View,Window,DecorView之间的关系
- FrameSize、WinSize、VisibleSize、VisibleOrigin概念理解
- linux设备模型(四 platform )
- 使用行列式公式求多边形面积
- poj 2241 The Tower of Babylon
- RecyclerView的使用
- [2015-08-11] python022
- 使用OGG的logdump工具检查OGG trail file中存在不存在相关表的记录
- OpenCV学习笔记:如何训练级联分类器
- HDU-1548 A strange lift(最短路[Spfa || BFS])
- 关于ListView的Adapter在调用notifyDataSetChanged()方法无效的原因