[PATCH v3 3/6] USB: Implement usb_device_match_id()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Match a usb_device with a table of IDs.

Signed-off-by: Bastien Nocera <hadess@xxxxxxxxxx>
Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
---
 drivers/usb/core/driver.c | 14 ++++++++++++++
 drivers/usb/core/usb.h    |  2 ++
 2 files changed, 16 insertions(+)

diff --git drivers/usb/core/driver.c drivers/usb/core/driver.c
index d3787d084937..697898327b44 100644
--- drivers/usb/core/driver.c
+++ drivers/usb/core/driver.c
@@ -800,6 +800,20 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
 }
 EXPORT_SYMBOL_GPL(usb_match_id);
 
+const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
+				const struct usb_device_id *id)
+{
+	if (!id)
+		return NULL;
+
+	for (; id->idVendor || id->idProduct ; id++) {
+		if (usb_match_device(udev, id))
+			return id;
+	}
+
+	return NULL;
+}
+
 static int usb_device_match(struct device *dev, struct device_driver *drv)
 {
 	/* devices and interfaces are handled separately */
diff --git drivers/usb/core/usb.h drivers/usb/core/usb.h
index bbe24817315e..f1dc63848219 100644
--- drivers/usb/core/usb.h
+++ drivers/usb/core/usb.h
@@ -69,6 +69,8 @@ extern int usb_match_one_id_intf(struct usb_device *dev,
 				 const struct usb_device_id *id);
 extern int usb_match_device(struct usb_device *dev,
 			    const struct usb_device_id *id);
+extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
+				const struct usb_device_id *id);
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev);
 
-- 
2.21.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux