1USB_MATCH_ID(9)                  USB Core APIs                 USB_MATCH_ID(9)
2
3
4

NAME

6       usb_match_id - find first usb_device_id matching device or interface
7

SYNOPSIS

9       const struct usb_device_id *
10                                                 usb_match_id(struct usb_interface * interface,
11                                                 const struct usb_device_id * id);
12

ARGUMENTS

14       interface
15           the interface of interest
16
17       id
18           array of usb_device_id structures, terminated by zero entry
19

DESCRIPTION

21       usb_match_id searches an array of usb_device_id´s and returns the first
22       one matching the device or interface, or null. This is used when
23       binding (or rebinding) a driver to an interface. Most USB device
24       drivers will use this indirectly, through the usb core, but some
25       layered driver frameworks use it directly. These device tables are
26       exported with MODULE_DEVICE_TABLE, through modutils, to support the
27       driver loading functionality of USB hotplugging.
28

WHAT MATCHES

30       The “match_flags” element in a usb_device_id controls which members are
31       used. If the corresponding bit is set, the value in the device_id must
32       match its corresponding member in the device or interface descriptor,
33       or else the device_id does not match.
34
35       “driver_info” is normally used only by device drivers, but you can
36       create a wildcard “matches anything” usb_device_id as a driver´s
37       “modules.usbmap” entry if you provide an id with only a nonzero
38       “driver_info” field. If you do this, the USB device driver´s probe
39       routine should use additional intelligence to decide whether to bind to
40       the specified interface.
41

WHAT MAKES GOOD USB_DEVICE_ID TABLES

43       The match algorithm is very simple, so that intelligence in driver
44       selection must come from smart driver id records. Unless you have good
45       reasons to use another selection policy, provide match elements only in
46       related groups, and order match specifiers from specific to general.
47       Use the macros provided for that purpose if you can.
48
49       The most specific match specifiers use device descriptor data. These
50       are commonly used with product-specific matches; the USB_DEVICE macro
51       lets you provide vendor and product IDs, and you can also match against
52       ranges of product revisions. These are widely used for devices with
53       application or vendor specific bDeviceClass values.
54
55       Matches based on device class/subclass/protocol specifications are
56       slightly more general; use the USB_DEVICE_INFO macro, or its siblings.
57       These are used with single-function devices where bDeviceClass doesn´t
58       specify that each interface has its own class.
59
60       Matches based on interface class/subclass/protocol are the most
61       general; they let drivers bind to any interface on a multiple-function
62       device. Use the USB_INTERFACE_INFO macro, or its siblings, to match
63       class-per-interface style devices (as recorded in bInterfaceClass).
64
65       Note that an entry created by USB_INTERFACE_INFO won´t match any
66       interface if the device class is set to Vendor-Specific. This is
67       deliberate; according to the USB spec the meanings of the interface
68       class/subclass/protocol for these devices are also vendor-specific, and
69       hence matching against a standard product class wouldn´t work anyway.
70       If you really want to use an interface-based match for such a device,
71       create a match record that also specifies the vendor ID. (Unforunately
72       there isn´t a standard macro for creating records like this.)
73
74       Within those groups, remember that not all combinations are meaningful.
75       For example, don´t give a product version range without vendor and
76       product IDs; or specify a protocol without its associated class and
77       subclass.
78
80Kernel Hackers Manual 2.6.         June 2019                   USB_MATCH_ID(9)
Impressum