1 --- a/drivers/usb/core/usb.c
2 +++ b/drivers/usb/core/usb.c
3 @@ -651,6 +651,71 @@ exit:
7 +static struct usb_device *match_device_name(struct usb_device *dev,
10 + struct usb_device *ret_dev = NULL;
13 + dev_dbg(&dev->dev, "check for name %s ...\n", name);
15 + /* see if this device matches */
16 + if (strcmp(dev_name(&dev->dev), name) == 0 ) {
17 + dev_dbg(&dev->dev, "matched this device!\n");
18 + ret_dev = usb_get_dev(dev);
22 + /* look through all of the children of this device */
23 + for (child = 0; child < dev->maxchild; ++child) {
24 + if (dev->children[child]) {
25 + usb_lock_device(dev->children[child]);
26 + ret_dev = match_device_name(dev->children[child], name);
27 + usb_unlock_device(dev->children[child]);
37 + * usb_find_device_by_name - find a specific usb device in the system
38 + * @name: the name of the device to find
40 + * Returns a pointer to a struct usb_device if such a specified usb
41 + * device is present in the system currently. The usage count of the
42 + * device will be incremented if a device is found. Make sure to call
43 + * usb_put_dev() when the caller is finished with the device.
45 + * If a device with the specified bus id is not found, NULL is returned.
47 +struct usb_device *usb_find_device_by_name(const char *name)
49 + struct list_head *buslist;
50 + struct usb_bus *bus;
51 + struct usb_device *dev = NULL;
53 + mutex_lock(&usb_bus_list_lock);
54 + for (buslist = usb_bus_list.next;
55 + buslist != &usb_bus_list;
56 + buslist = buslist->next) {
57 + bus = container_of(buslist, struct usb_bus, bus_list);
60 + usb_lock_device(bus->root_hub);
61 + dev = match_device_name(bus->root_hub, name);
62 + usb_unlock_device(bus->root_hub);
67 + mutex_unlock(&usb_bus_list_lock);
70 +EXPORT_SYMBOL_GPL(usb_find_device_by_name);
73 * usb_get_current_frame_number - return current bus frame number
74 * @dev: the device whose bus is being queried
75 --- a/include/linux/usb.h
76 +++ b/include/linux/usb.h
77 @@ -540,6 +540,7 @@ extern int usb_reset_device(struct usb_d
78 extern void usb_queue_reset_device(struct usb_interface *dev);
80 extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
81 +extern struct usb_device *usb_find_device_by_name(const char *name);
83 /* USB autosuspend and autoresume */
84 #ifdef CONFIG_USB_SUSPEND