From patchwork Sun Jun 9 21:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1945587 X-Patchwork-Delegate: mkorpershoek@baylibre.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=HqRBwxrD; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=hJ/PlLLV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vy7Xn1qfHz20KL for ; Mon, 10 Jun 2024 07:36:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 41BC1883FB; Sun, 9 Jun 2024 23:35:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="HqRBwxrD"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="hJ/PlLLV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6FA988415; Sun, 9 Jun 2024 23:35:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 069B7883BA for ; Sun, 9 Jun 2024 23:35:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Vy7Wq6nMJz9slg; Sun, 9 Jun 2024 23:35:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1717968919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mLz/FHpOzws0sEoP+fG5vNKsvMnl1Pwo+/6tWTvY4x8=; b=HqRBwxrDKyfxWF/88qqoeuzxXiwNERRo1JixoA8n+6T3VnPI9OSJ8sAqOfiBSSmweIY1I5 EmNx3Wj+aQFEE44xj4csDRb9dCVwNchTWnYoOoAEGRa3oAilHlkkpwla2PnHzSQfpshsCO 50z+oPGwqdbyflsCbsZ4AzvsscmDX86fyvpJG58236Idx+zcq+08vpskS3N8FXGI0jwH7W iBUJbhNh00YnbpCBsfF6bbz5VpaHl9q2AOLFTSStwe+98wQY7eno85OTIHuRWZM8wtITUN Jw7/NfrPVMk6YTUy4815rBLuHZRhhnfZWDKH2i2+xf06Bfy+L8u0tw9HbbLvAQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1717968918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mLz/FHpOzws0sEoP+fG5vNKsvMnl1Pwo+/6tWTvY4x8=; b=hJ/PlLLVIJ0Qjji9pXuoOTEhWy5O3ey19FVKL+vC6rpGDm/Kj4DK4kbmHdBC29m/SeSk1G U2pQeIqkMcuWyg3aUljoVvP2EG3aMt4MkICn7C711mEaJ6obEg2ncWogDL+Ajesah+e9Yy eQ5z8N3n3hqMSVB4LJBtv0ZXu6NL1OBNKTmqvRVHPfnrxoP8r4qE6G0uhj2Ativ21WzNw1 +L0g9+Hggz4wpm4XN3u+GFL1mlElO8iUVFO0FhxwbTOqqxJvDfgrSqOEBgZD2BmCMxVVd9 DP/+cVvjZ4XZUQrTxMzYIGYtPvhBmNfJxrQzQ8jSpUaJDuJprYx2LE7icAacrg== To: u-boot@lists.denx.de Cc: Marek Vasut , Alexander Sverdlin , Felipe Balbi , Lukasz Majewski , Mattijs Korpershoek , Nishanth Menon , Simon Glass , Thinh Nguyen , Tom Rini Subject: [PATCH 5/6] usb: gadget: Add full ep_matches() check past .match_ep() callback Date: Sun, 9 Jun 2024 23:32:18 +0200 Message-ID: <20240609213449.194762-5-marek.vasut+renesas@mailbox.org> In-Reply-To: <20240609213449.194762-1-marek.vasut+renesas@mailbox.org> References: <20240609213449.194762-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 38660324d358da9397b X-MBO-RS-META: q7s1ymf3jjpkniqn5yzzjdz5qu48hzw8 X-Rspamd-Queue-Id: 4Vy7Wq6nMJz9slg X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean If .match_ep() callback returns non-NULL endpoint, immediately check its usability and if the returned endpoint is usable, stop search and return the endpoint. Otherwise, continue with best effort search for usable endpoint. Currently the code would attempt the best effort search in any case, which may find another unexpected endpoint. It is likely that the intention of the original code was to stop the search early. Fixes: 77dcbdf3c1ce ("usb: gadget: Add match_ep() op to usb_gadget_ops") Signed-off-by: Marek Vasut Reviewed-by: Mattijs Korpershoek Tested-by: Mattijs Korpershoek # on vim3 --- Cc: Alexander Sverdlin Cc: Felipe Balbi Cc: Lukasz Majewski Cc: Mattijs Korpershoek Cc: Nishanth Menon Cc: Simon Glass Cc: Thinh Nguyen Cc: Tom Rini Cc: u-boot@lists.denx.de --- drivers/usb/gadget/epautoconf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 09950ceeaed..66599ce8efa 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -247,8 +247,11 @@ struct usb_ep *usb_ep_autoconfig( return ep; } - if (gadget->ops->match_ep) + if (gadget->ops->match_ep) { ep = gadget->ops->match_ep(gadget, desc, NULL); + if (ep && ep_matches(gadget, ep, desc)) + return ep; + } /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry(ep, &gadget->ep_list, ep_list) {