USB: Also match device drivers using the ->match vfunc

We only ever used the ID table matching before, but we should also support
open-coded match functions.

Fixes: 88b7381a93 ("USB: Select better matching USB drivers when available")
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Cc: stable <stable@vger.kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20200818110445.509668-1-hadess@hadess.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Bastien Nocera 2020-08-18 13:04:43 +02:00 committed by Greg Kroah-Hartman
parent d54343a877
commit adb6e6ac20
1 changed files with 3 additions and 2 deletions

View File

@ -205,8 +205,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
udrv = to_usb_device_driver(drv);
if (udrv == &usb_generic_driver)
return 0;
return usb_device_match_id(udev, udrv->id_table) != NULL;
if (usb_device_match_id(udev, udrv->id_table) != NULL)
return 1;
return (udrv->match && udrv->match(udev));
}
static bool usb_generic_driver_match(struct usb_device *udev)