当前位置: 首页 > 工具软件 > aotoo-hub > 使用案例 >

hub_probe被调用

阮星火
2023-12-01

刚才在hub_thread睡眠了,但是由于有roothub的存在,hub_probe在初始化控制器的时候被调用。

static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
	struct usb_host_interface *desc;
	struct usb_endpoint_descriptor *endpoint;
	struct usb_device *hdev;
	struct usb_hub *hub;

	desc = intf->cur_altsetting;
	hdev = interface_to_usbdev(intf);

	/* Hubs have proper suspend/resume support */
	usb_enable_autosuspend(hdev);

	if (hdev->level == MAX_TOPO_LEVEL) {<span style="color:#990000;"><strong>//不得超过6层</strong></span>
		dev_err(&intf->dev,
			"Unsupported bus topology: hub nested too deep\n");
		return -E2BIG;
	}

#ifdef	CONFIG_USB_OTG_BLACKLIST_HUB
	if (hdev->parent) {
		dev_warn(&intf->dev, "ignoring external hub\n");
		return -ENODEV;
	}
#endif

	/* Some hubs have a subclass of 1, which AFAICT according to the */
	/*  specs is not defined, but it works */
	if ((desc->desc.bInterfaceSubClass != 0) && //规定<span style="font-family: Arial, Helvetica, sans-serif;">bInterfaceSubClass=0,但有些是=1</span>

	    (desc->desc.bInterfaceSubClass != 1)) {
descriptor_error:
		dev_err (&intf->dev, "bad descriptor, ignoring hub\n");
		return -EIO;
	}

	/* Multiple endpoints? What kind of mutant ninja-hub is this? */
	if (desc->desc.bNumEndpoints != 1) <span style="color:#990000;"><strong>//hub只有一个端点就是中断端点</strong></span>
		goto descriptor_error;

	endpoint = &desc->endpoint[0].desc;

	/* If it's not an interrupt in endpoint, we'd better punt! */
	if (!usb_endpoint_is_int_in(endpoint)) <span style="color:#990000;"><strong>//判断是否为中断端点</strong></span>
		goto descriptor_error;

	/* We found a hub */
	dev_info (&intf->dev, "USB hub found\n");

	hub = kzalloc(sizeof(*hub), GFP_KERNEL);
	if (!hub) {
		dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n");
		return -ENOMEM;
	}

	kref_init(&hub->kref);
	INIT_LIST_HEAD(&hub->event_list);
	hub->intfdev = &intf->dev;
	hub->hdev = hdev;
	INIT_DELAYED_WORK(&hub->leds, led_work);<span style="color:#990000;"><strong>//初始化一工作</strong></span>
	INIT_DELAYED_WORK(&hub->init_work, NULL);
	usb_get_intf(intf);

	usb_set_intfdata (intf, hub);<strong><span style="color:#990000;">//将struct usb_interface与struct usb_hub给结合在了一起,</span></strong>
<strong><span style="color:#990000;"><span style="white-space:pre">				</span>     //以后可以通过<span style="font-family: Arial, Helvetica, sans-serif;">struct usb_interface找到对应的struct usb_hub</span></span></strong>

	intf->needs_remote_wakeup = 1;

	if (hdev->speed == USB_SPEED_HIGH)
		highspeed_hubs++;

	if (hub_configure(hub, endpoint) >= 0)//<strong><span style="color:#990000;">配置hub,如果返回小于0表示出错</span></strong>
		return 0;

	hub_disconnect (intf);
	return -ENODEV;
}
由上可以看出,

1、hub只有一个中断端点

2、最多不能超过7层



 类似资料: