免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2551 | 回复: 2
打印 上一主题 下一主题

powerpc下I2C的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-26 20:15 |只看该作者 |倒序浏览
所有的powerpc 的I2C适配器驱动都在/driver/i2c/busses/I2c-mpc.c文件中。
适配器的驱动是of_platform_driver,
/* Structure for a device driver */
static struct of_platform_driver mpc_i2c_driver = {
        .match_table        = mpc_i2c_of_match,
        .probe                = fsl_i2c_probe,
        .remove                = __devexit_p(fsl_i2c_remove),
        .driver                = {
                .owner        = THIS_MODULE,
                .name        = DRV_NAME,//mpc-i2c
        },
};
在这里我们看一下of_platform_bus_type,
struct bus_type of_platform_bus_type = {
       .uevent        = of_device_uevent,
};
可以看到,这里没有match方法。
module_init(fsl_i2c_init) -> fsl_i2c_init -> of_register_platform_driver(&mpc_i2c_driver)
在这里会调用of_platform总线的match函数of_platform_bus_match去做设备和驱动的匹配,
of_platform_bus_match函数在比较了驱动的match-table和设备node中的相关字段后( compatible = "fsl-i2c" ),若匹配,进入fsl_i2c_probe。但是我们看到在这里of_platform总线的结构体里没有match方法。是不是在注册适配器的时候是不要match设备的名子的?

论坛徽章:
0
2 [报告]
发表于 2013-01-18 14:03 |只看该作者
想问struct bus_type of_platform_bus_type = {
       .uevent        = of_device_uevent,
};
这里的uevent什么时候调用?

论坛徽章:
0
3 [报告]
发表于 2013-01-18 19:06 |只看该作者
这是platform_bus 下的uevent函数,是在产生事件时才会调用。如在调用device_add函数时,在调用kobject_uevent(&dev->kobj, KOBJ_ADD)时会产生一个事件,这个函数中会调用相应的kset_uevent_ops的uevent函数,这里即为dev_uevent(),看一下这个函数的代码片段:
static int dev_uevent(struct kset *kset, struct kobject *kobj, struct kobj_uevent_env *env)
{
..............................

       /* have the bus specific function add its stuff */

       if (dev->bus && dev->bus->uevent) {

              retval = dev->bus->uevent(dev, env);

              if (retval)

                     pr_debug("device: '%s': %s: bus uevent() returned %d\n",

                             dev_name(dev), __func__, retval);

       }
.........................
}

从这里看到如果bus->uevent()函数存在则会调用它。也就是调用of_device_uevent.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP