免费注册 查看新帖 |

Chinaunix

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

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

论坛徽章:
0
1 [报告]
发表于 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
2 [报告]
发表于 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
3 [报告]
发表于 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