]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: gadget: Add full ep_matches() check past .match_ep() callback
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sun, 9 Jun 2024 21:32:18 +0000 (23:32 +0200)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Fri, 5 Jul 2024 12:01:19 +0000 (14:01 +0200)
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 <marek.vasut+renesas@mailbox.org>
Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Link: https://lore.kernel.org/r/20240609213449.194762-5-marek.vasut+renesas@mailbox.org
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
drivers/usb/gadget/epautoconf.c

index 09950ceeaed069f290e970adf7db70392dca588a..66599ce8efabab373f46f9c55ec3f7fbb916e6e9 100644 (file)
@@ -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) {