On Wed, Apr 12, 2023 at 01:54:12PM +0200, Oliver Neukum wrote: > On 10.04.23 21:37, Alan Stern wrote: > > Hi, > > To make this checking as simple as possible, we now add a couple of > > utility routines to the USB core. usb_check_bulk_endpoints() and > > usb_check_int_endpoints() take an interface pointer together with a > > list of endpoint addresses (numbers and directions). They check that > > the interface's current alternate setting includes endpoints with > > those addresses and that each of these endpoints has the right type: > > bulk or interrupt, respectively. > > > > Although we already have usb_find_common_endpoints() and related > > routines meant for a similar purpose, they are not well suited for > > this kind of checking. Those routines find endpoints of various > > kinds, but only one (either the first or the last) of each kind, and > > they don't verify that the endpoints' addresses agree with what the > > caller expects. > > these will do the job. Yet this strikes me as unelegant. That is > if you define a data structure to match against, why not > add a pointer to it to struct usb_device_id and use that? Struct usb_device_id doesn't seem like the right place. Struct usb_driver would be more appropriate. The drivers that need this have only one entry in their match table, which means that drivers with large match tables (which would require a lot of extra space for the new pointers) don't need it. > Basically the table of endpoints you are creating is a description of > a device. Why add code for checking it to each probe() method > that needs it? True, the checks could be centralized in usb_probe_interface(). What do you think about doing it that way? Alan Stern