手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux设备模型之platform

[日期:2012-01-30] 来源:csdn  作者:gdt_a20 [字体:大 中 小]

三、platform_driver的注册

      driver部分比较简单,其结构为:

            struct platform_driver {
                      int (*probe)(struct platform_device *);
                      int (*remove)(struct platform_device *);
                      void (*shutdown)(struct platform_device *);
                      int (*suspend)(struct platform_device *, pm_message_t state);
                      int (*resume)(struct platform_device *);
                      struct device_driver driver;                                             //内嵌的标准driver结构           
                      const struct platform_device_id *id_table;                       //支持的设备id表
             };

  注册函数分析:

  int platform_driver_register(struct platform_driver *drv)
  {
                      drv->driver.bus = &platform_bus_type;                          //设置bus
                      if (drv->probe)                                                             //如果platform_driver下的probe为真,就把内嵌
                                drv->driver.probe = platform_drv_probe;               //的标准driver的probe设置成platform_drv_probe
                      if (drv->remove)                                                           //可见外层的probe比内层的优先级别高
                                drv->driver.remove = platform_drv_remove;
                      if (drv->shutdown)
                                 drv->driver.shutdown = platform_drv_shutdown;

                      return driver_register(&drv->driver);                               //注册标准driver
  }

四、总结

       分析了platform架构以及初始化以及注册流程,结合前面关于标注模型的理解,理解这部分,应当很简单!  ^_^

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款