From patchwork Sat Jul 25 09:13:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 11684907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F657138C for ; Sat, 25 Jul 2020 09:13:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50C7C20719 for ; Sat, 25 Jul 2020 09:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgGYJNP (ORCPT ); Sat, 25 Jul 2020 05:13:15 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:40477 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgGYJNP (ORCPT ); Sat, 25 Jul 2020 05:13:15 -0400 X-Originating-IP: 82.255.60.242 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B6AC040007; Sat, 25 Jul 2020 09:13:12 +0000 (UTC) Message-ID: <616e0a918957ce9936478574a4856df742c20ad7.camel@hadess.net> Subject: [PATCH 1/3] USB: Simplify USB ID table match From: Bastien Nocera To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Alan Stern Date: Sat, 25 Jul 2020 11:13:12 +0200 User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org usb_device_match_id() supports being passed NULL tables, so no need to check for it. Signed-off-by: Bastien Nocera Acked-by: Alan Stern --- drivers/usb/core/generic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index 4626227a6dd2..b6f2d4b44754 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c @@ -205,8 +205,6 @@ static int __check_usb_generic(struct device_driver *drv, void *data) udrv = to_usb_device_driver(drv); if (udrv == &usb_generic_driver) return 0; - if (!udrv->id_table) - return 0; return usb_device_match_id(udev, udrv->id_table) != NULL; } From patchwork Sat Jul 25 09:14:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 11684909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06219138C for ; Sat, 25 Jul 2020 09:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA8D220714 for ; Sat, 25 Jul 2020 09:14:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbgGYJOL (ORCPT ); Sat, 25 Jul 2020 05:14:11 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:34533 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725944AbgGYJOJ (ORCPT ); Sat, 25 Jul 2020 05:14:09 -0400 X-Originating-IP: 82.255.60.242 Received: from classic (lns-bzn-39-82-255-60-242.adsl.proxad.net [82.255.60.242]) (Authenticated sender: hadess@hadess.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id AAD9440004; Sat, 25 Jul 2020 09:14:07 +0000 (UTC) Message-ID: <25f9d978b791d25583b18f4b5d0a929e031fec1f.camel@hadess.net> Subject: [PATCH 2/3] USB: Also check for ->match From: Bastien Nocera To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Alan Stern Date: Sat, 25 Jul 2020 11:14:07 +0200 User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org We only ever used a the ID table matching before, but we should probably also support an open-coded match function. Fixes: 88b7381a939de ("USB: Select better matching USB drivers when available") Signed-off-by: Bastien Nocera Acked-by: Alan Stern --- drivers/usb/core/generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index b6f2d4b44754..2b2f1ab6e36a 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c @@ -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)