From: Marek Vasut Date: Mon, 21 May 2018 17:08:14 +0200 Subject: [U-Boot] [PATCH] dm: usb: setup ehci gadget before usb is probed In-Reply-To: <20180521150006.32467-1-ramon.fried@gmail.com> References: <20180521150006.32467-1-ramon.fried@gmail.com> Message-ID: <706b072d-a7bf-d253-64c2-b9e49941afcd@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05/21/2018 05:00 PM, Ramon Fried wrote: > usb_setup_ehci_gadget() looks for a loaded USB class driver, > then it unloads it and loads it again as a device instead of host. > This change loads the USB class driver as device if it wasn't loaded > in the first place. To achieve what ? What is the purpose of this patch ? Are you fixing a bug or improving the code or what ? > Signed-off-by: Ramon Fried > --- > drivers/usb/host/usb-uclass.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c > index 611ea97a72..7ab7e8990c 100644 > --- a/drivers/usb/host/usb-uclass.c > +++ b/drivers/usb/host/usb-uclass.c > @@ -380,17 +380,22 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index) > > int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) > { > + TRACE(); > struct usb_platdata *plat; > struct udevice *dev; > int ret; > > /* Find the old device and remove it */ > ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); > - if (ret) > - return ret; > - ret = device_remove(dev, DM_REMOVE_NORMAL); > - if (ret) > - return ret; > + if (ret) { > + ret = uclass_find_device(UCLASS_USB, 0, &dev); > + if (ret) > + return ret; > + } else { > + ret = device_remove(dev, DM_REMOVE_NORMAL); > + if (ret) > + return ret; > + } > > plat = dev_get_platdata(dev); > plat->init_type = USB_INIT_DEVICE; > -- Best regards, Marek Vasut