Skip to content

Commit aeebf2b

Browse files
hadessgregkh
authored andcommitted
USB: Implement usb_device_match_id()
Match a usb_device with a table of IDs. Signed-off-by: Bastien Nocera <[email protected]> Acked-by: Alan Stern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c9d5033 commit aeebf2b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/usb/core/driver.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,20 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
800800
}
801801
EXPORT_SYMBOL_GPL(usb_match_id);
802802

803+
const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
804+
const struct usb_device_id *id)
805+
{
806+
if (!id)
807+
return NULL;
808+
809+
for (; id->idVendor || id->idProduct ; id++) {
810+
if (usb_match_device(udev, id))
811+
return id;
812+
}
813+
814+
return NULL;
815+
}
816+
803817
static int usb_device_match(struct device *dev, struct device_driver *drv)
804818
{
805819
/* devices and interfaces are handled separately */

drivers/usb/core/usb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ extern int usb_match_one_id_intf(struct usb_device *dev,
6969
const struct usb_device_id *id);
7070
extern int usb_match_device(struct usb_device *dev,
7171
const struct usb_device_id *id);
72+
extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
73+
const struct usb_device_id *id);
7274
extern void usb_forced_unbind_intf(struct usb_interface *intf);
7375
extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev);
7476

0 commit comments

Comments
 (0)