这个是驱动注册需要的一个重要的结构体。
驱动注册的头文件是 #include <linux/platform_device.h>
驱动注册初始化函数DriverState = platform_driver_register(&hello_driver); //注册函数
驱动注册卸载函数platform_driver_unregister(&hello_driver); //卸载函数
需要定义一个结构体
struct platform_driver hello_driver = {
.probe = hello_probe, //初始化函数
.remove = hello_remove, //移除
.shutdown = hello_shutdown, //
.suspend = hello_suspend, //休眠
.resume = hello_resume, //唤醒
.driver = {
.name = DRIVER_NAME, //这个必须和注册的设备保持一致
.owner = THIS_MODULE, //
}
};
当然这个上边的函数需要编写。驱动注册也就完成了。
网友评论