+ -
当前位置:首页 → 问答吧 → USB probe 问题

USB probe 问题

时间:2010-12-28

来源:互联网

在 Linux 2.6.22.1 内核中 在 UHCI 中执行了register_root_hub() 函数,而在此函数中最终会调用 hub_probe() 函数
问题就在这:hub_probe() 函数第一个参数 struct usb_interface *intf 是通过一个宏而得到的!
  1. to_usb_interface(dev)

  2. #define to_usb_interface(d) container_of(d, struct usb_interface, dev)
复制代码
dev 为 struct usb_device 结构中 struct device dev 的指针!而此处是怎么得到 struct usb_interface *intf 的?很困惑!请高手解答!!!!!!!!

作者: zd零   发布时间: 2010-12-28

把container_of搞明白,自然知道intf如何得到。

container_of最后的dev其实指struct usb_interface中的dev。

作者: picktracy   发布时间: 2010-12-28