 +	spin_unlock(&drv->dynids.lock);
 +}
 +
- static int usb_device_match(struct device *dev, struct device_driver *drv)
++static inline int is_usb_device_driver(struct device_driver *drv)
++{
++	return container_of(drv, struct usbdrv_wrap, driver)->
++			for_devices;
++}
++
++static int usb_device_id_dump_driver(struct device_driver *drv, void *data)
++{
++	struct usb_driver *usb_drv;
++
++	if (is_usb_device_driver(drv))
++		return 0;
++	usb_drv = to_usb_driver(drv);
++
++	usb_device_id_dump_static(usb_drv);
++	usb_device_id_dump_dynamic(usb_drv);
++
++	return 0;
++}
++
++static int usb_ids_dumped;
++
++struct bus_type hid_bus_type;
++
++static void usb_device_id_dump_all(void)
++{
++	if (usb_ids_dumped)
++		return;
++	usb_ids_dumped = 1;
++	bus_for_each_drv(&usb_bus_type, NULL, NULL, usb_device_id_dump_driver);
++	bus_for_each_drv(&hid_bus_type, NULL, NULL, hid_device_id_dump_driver);
++}
++
+ const struct hid_device_id *hid_match_device(struct hid_device *hdev,
+ 					     struct hid_driver *hdrv)
  {
- 	/* devices and interfaces are handled separately */
-@@ -814,6 +847,9 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
- 		intf = to_usb_interface(dev);
- 		usb_drv = to_usb_driver(drv);
+ 	struct hid_dynid *dynid;
  
-+		usb_device_id_dump_static(usb_drv);
-+		usb_device_id_dump_dynamic(usb_drv);
++	usb_device_id_dump_all();
 +
- 		id = usb_match_id(intf, usb_drv->id_table);
- 		if (id)
- 			return 1;
+ 	spin_lock(&hdrv->dyn_lock);
+ 	list_for_each_entry(dynid, &hdrv->dyn_list, list) {
+ 		if (hid_match_one_id(hdev, &dynid->id)) {

commit 17edce0094c7d7b78b05748d5ce54d68d9bcb419
Author: Andrey Konovalov <andreyknvl@google.com>
Date:   Wed Sep 27 17:06:15 2017 +0200

    usb-fuzzer: dump usb device ids on enumeration

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 210b81a56e1a..6547515b8a2d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2114,11 +2114,45 @@ static void hid_free_dynids(struct hid_driver *hdrv)
 	spin_unlock(&hdrv->dyn_lock);
 }
 

+	spin_unlock(&hdrv->dyn_lock);
+}
+
+static int hid_device_id_dump_driver(struct device_driver *drv, void *data)
+{
+	struct hid_driver *hdrv = to_hid_driver(drv);
+
+	hid_device_id_dump_static(hdrv);
+	hid_device_id_dump_dynamic(hdrv);
+
+	return 0;
+}
+
+static void usb_device_id_dump_one(const struct usb_device_id *id)
+{
+	char buffer[128];
