免费注册 查看新帖 |

Chinaunix

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

linux 总线 和 总线设备本身 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-27 00:49 |只看该作者 |倒序浏览
本帖最后由 karsa 于 2010-04-27 00:57 编辑

最近在看LDD3,发现了两个问题,就是:
1.在注册总线时,总线本身的device也是要注册的,我的问题是:怎么就知道我注册的设备他就代表这条总线呢?就是device和bus_type怎么联系上。(注意,是总线本身的设备,而不是挂在总线上的设备和驱动)(比如LDD3上的lddbus这个例子)
2.还有一个问题,就是我在看SDIO驱动的时候,发现注册了bus_register(&sdio_bus_type);但是死活找不到sdio总线本身设备的注册,他肯定是被注册了,但是是在哪里,什么时候注册的,我还搞不清楚。
可能是我不够认真,但是我找了几遍都找不到答案,希望牛人能帮我解答下,非常感谢

论坛徽章:
0
2 [报告]
发表于 2010-04-27 19:05 |只看该作者
回复 1# karsa


   大侠们,帮帮忙啊,up

论坛徽章:
0
3 [报告]
发表于 2010-04-27 20:59 |只看该作者
This pci_bus_type variable is registered with the driver core when the PCI subsystem is loaded in the kernel with a call to bus_register

论坛徽章:
0
4 [报告]
发表于 2010-04-28 00:11 |只看该作者
This pci_bus_type variable is registered with the driver core when the PCI subsystem is loaded in th ...
jieao111 发表于 2010-04-27 20:59


还是不明白,你说的是:当pci子系统被装载到内核中的时候,pci_bus_type将通过bus_register函数向driver core中注册。
但是PCI bus本身也是个设备,这个设备什么时候被注册的呢?
不知道是你说清楚了我不明白,还是你没说清楚,我接触linux的时间也不长,是个菜鸟,能详细点解释吗,谢谢

论坛徽章:
0
5 [报告]
发表于 2010-05-05 12:15 |只看该作者
We have seen how the lddbus code registers its bus type. However, an actual bus is a device and must be registered separately. For simplicity, the lddbus module supports only a single virtual bus, so the driver sets up its device at compile time:

static void ldd_bus_release(struct device *dev)

{

    printk(KERN_DEBUG "lddbus release\n");

}

   

struct device ldd_bus = {

    .bus_id   = "ldd0",

    .release  = ldd_bus_release

};


This is a top-level bus, so the parent and bus fields are left NULL. We have a simple, no-op release method, and, as the first (and only) bus, its name is ldd0. This bus device is registered with:

ret = device_register(&ldd_bus);

if (ret)

    printk(KERN_NOTICE "Unable to register ldd0\n");


Once that call is complete, the new bus can be seen under /sys/devices in sysfs. Any devices added to this bus then shows up under /sys/devices/ldd0/.

论坛徽章:
0
6 [报告]
发表于 2010-05-05 12:19 |只看该作者
这个一个bus是一个device(即这个bus结构体内也有device这个成员),而这个bus的结构体内有bus_type这个成员,所以注册的时候就联系一起了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP