美文网首页
4.驱动注册(iTOP4412)

4.驱动注册(iTOP4412)

作者: 飒风灬 | 来源:发表于2018-04-21 19:22 被阅读0次

    这个是驱动注册需要的一个重要的结构体。

    驱动注册的头文件是 #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,    //

    }

    };

    当然这个上边的函数需要编写。驱动注册也就完成了。

    相关文章

      网友评论

          本文标题:4.驱动注册(iTOP4412)

          本文链接:https://www.haomeiwen.com/subject/fbxakftx.html