diff mbox series

usb: Use the first available device for ehci_gadget

Message ID 20211105165255.57736-1-sean.anderson@seco.com
State Accepted
Commit 821ca608d81640f1ed10fc5540eb8df18dfa6679
Delegated to: Simon Glass
Headers show
Series usb: Use the first available device for ehci_gadget | expand

Commit Message

Sean Anderson Nov. 5, 2021, 4:52 p.m. UTC
For whatever reason, usb_setup_ehci_gadget removes and probes USB device
0. However, not all systems have a device 0. Use the first device
instead.

The device probed should probably have something to do with the
controller (as specified by e.g. ums <controller> or fastboot
<controller>). In fact, I find it odd that we probe the USB device in
the first place, because this is just to set up the gadget itself.
Presumably, the controller should be probed by usb_gadget_initialize
somehow.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

 drivers/usb/host/usb-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass Nov. 6, 2021, 3:16 a.m. UTC | #1
On Fri, 5 Nov 2021 at 10:53, Sean Anderson <sean.anderson@seco.com> wrote:
>
> For whatever reason, usb_setup_ehci_gadget removes and probes USB device
> 0. However, not all systems have a device 0. Use the first device
> instead.
>
> The device probed should probably have something to do with the
> controller (as specified by e.g. ums <controller> or fastboot
> <controller>). In fact, I find it odd that we probe the USB device in
> the first place, because this is just to set up the gadget itself.
> Presumably, the controller should be probed by usb_gadget_initialize
> somehow.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
>  drivers/usb/host/usb-uclass.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Jan. 26, 2022, 3:37 p.m. UTC | #2
On Fri, 5 Nov 2021 at 10:53, Sean Anderson <sean.anderson@seco.com> wrote:
>
> For whatever reason, usb_setup_ehci_gadget removes and probes USB device
> 0. However, not all systems have a device 0. Use the first device
> instead.
>
> The device probed should probably have something to do with the
> controller (as specified by e.g. ums <controller> or fastboot
> <controller>). In fact, I find it odd that we probe the USB device in
> the first place, because this is just to set up the gadget itself.
> Presumably, the controller should be probed by usb_gadget_initialize
> somehow.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
>  drivers/usb/host/usb-uclass.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index fd39c3345c..27e2fc6fcd 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -396,7 +396,7 @@  int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
 	int ret;
 
 	/* Find the old device and remove it */
-	ret = uclass_find_device_by_seq(UCLASS_USB, 0, &dev);
+	ret = uclass_find_first_device(UCLASS_USB, &dev);
 	if (ret)
 		return ret;
 	ret = device_remove(dev, DM_REMOVE_NORMAL);
@@ -419,7 +419,7 @@  int usb_remove_ehci_gadget(struct ehci_ctrl **ctlrp)
 	int ret;
 
 	/* Find the old device and remove it */
-	ret = uclass_find_device_by_seq(UCLASS_USB, 0, &dev);
+	ret = uclass_find_first_device(UCLASS_USB, &dev);
 	if (ret)
 		return ret;
 	ret = device_remove(dev, DM_REMOVE_NORMAL);