作家
登录

Linux平台总线驱动设备模型

作者: 来源: 2017-11-16 16:05:49 阅读 我要评论

  • };   
    1. int platform_driver_register(struct platform_driver *drv)   
    2. {   
    3.     drv->driver.bus = &platform_bus_type;   
    4.     if (drv->probe)   
    5.         drv->driver.probe = platform_drv_probe;   
    6.     if (drv->remove)   
    7.         drv->driver.remove = platform_drv_remove;   
    8.     if (drv->shutdown)   
    9.         drv->driver.shutdown = platform_drv_shutdown;   
    10.     if (drv->suspend)   
    11.         drv->driver.suspend = platform_drv_suspend;   
    12.     if (drv->resume)   
    13.         drv->driver.resume = platform_drv_resume;   
    14.     return driver_register(&drv->driver);   
    15. }   

    先初始化platform_driver里的driver,该driver的类型为device_driver,设置driver的bus为platform_bus_type;设置driver的probe为platform_drv_probe;设置driver的remove为platform_drv_remove;设置driver的shutdown为platform_drv_shutdown;设置driver的suspend为platform_drv_suspend;设置driver的resume为platform_drv_resume,最后调用driver_register函数来注册平台驱动。

    相反地,要刊出平台驱动的话,应用platform_driver_unregister函数

    platform_device_del函数调用device_del函数来删除平台设备,响应地,要释放资本竽暌功调用release_resource函数,前提是资本的类型必须为IORESOURCE_MEM或者IORESOURCE_IO

    1. void platform_driver_unregister(struct platform_driver *drv)   
    2. {   
    3.     driver_unregister(&drv->driver);   
    4. }   

    【编辑推荐】

    1. Linux体系启动故障若何修复?这几个案例帮你解决问题~
    2. 面试Linux运维必定会问到Shell脚本的┞封24个问题
    3. Linux内核4.14宣布:快来看看Linus的总结和超多新特点
    4. 慕尼黑放弃 Linux,2020 年或将周全迁入 Windows
    5. Linux Lite第一个支撑Linux 4.14及若何安装
    【义务编辑:庞桂玉 TEL:(010)68476606】

      推荐阅读

      Linux Lite第一个支持Linux 4.14及如何安装

    Tech Neo技巧沙龙 | 11月25号,九州云/ZStack与您一路商量云时代收集界线治理实践 Linux Lite保护者Jerry Bezencon再次初次在Twitter上宣布他的基于Ubuntu的发行版的软件库中最新的Linux内>>>详细阅读


    本文标题:Linux平台总线驱动设备模型

    地址:http://www.17bianji.com/lsqh/38937.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)