Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: dwc2: Postponed gadget registration to the udc class driver

During dwc2 driver probe, after gadget registration to the udc class
driver, if exist any builtin function driver it immediately bound to
dwc2 and after init host side (dwc2_hcd_init()) stucked in host mode.
Patch postpone gadget registration after host side initialization done.

Fixes: 117777b2c3bb9 ("usb: dwc2: Move gadget probe function into platform code")
Reported-by: kbuild test robot <lkp@intel.com>
Tested-by: Marek Vasut <marex@denx.de>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
Link: https://lore.kernel.org/r/f21cb38fecc72a230b86155d94c7e60c9cb66f58.1591690938.git.hminas@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Minas Harutyunyan and committed by
Greg Kroah-Hartman
207324a3 5d802192

+11 -6
-6
drivers/usb/dwc2/gadget.c
··· 4920 4920 epnum, 0); 4921 4921 } 4922 4922 4923 - ret = usb_add_gadget_udc(dev, &hsotg->gadget); 4924 - if (ret) { 4925 - dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, 4926 - hsotg->ctrl_req); 4927 - return ret; 4928 - } 4929 4923 dwc2_hsotg_dump(hsotg); 4930 4924 4931 4925 return 0;
+11
drivers/usb/dwc2/platform.c
··· 575 575 if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) 576 576 dwc2_lowlevel_hw_disable(hsotg); 577 577 578 + #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ 579 + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) 580 + /* Postponed adding a new gadget to the udc class driver list */ 581 + if (hsotg->gadget_enabled) { 582 + retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget); 583 + if (retval) { 584 + dwc2_hsotg_remove(hsotg); 585 + goto error_init; 586 + } 587 + } 588 + #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */ 578 589 return 0; 579 590 580 591 error_init: