天嵌 ARM开发社区

 找回密码
 注册
查看: 2108|回复: 1

platform_driver_register函数分析 求解惑

[复制链接]
wang12zhedi 发表于 2012-12-25 13:04:05 | 显示全部楼层 |阅读模式
int platform_driver_register(struct platform_driver *drv)
{///                                         &s3c2410fb_driver
        drv->driver.bus = &platform_bus_type;//总线类型定义为platform_bus_type
        if (drv->probe)
                drv->driver.probe = platform_drv_probe;
        if (drv->remove)
                drv->driver.remove = platform_drv_remove;
        if (drv->shutdown)
                drv->driver.shutdown = platform_drv_shutdown;

        return driver_register(&drv->driver);
}

这个函数没有几句代码  但是 不理解

例如
        if (drv->probe)
                drv->driver.probe = platform_drv_probe;
这句怎么去理解呢?
embedsky_lhh 发表于 2012-12-26 09:34:37 | 显示全部楼层
你看下 struct platform_driver的原型就明白了,struct platform_driver 下有 几个成员变量是几个函数指针,其中就有probe......, 而 struct platform_driver其成员有driver的成员变量,而一般.driver.probe是内核默认的,不提供给用户实现,就算实现了也会覆盖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-5 15:36 , Processed in 1.046875 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表