Skip to content

Commit

Permalink
usb: dwc2: Postponed gadget registration to the udc class driver
Browse files Browse the repository at this point in the history
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: 117777b ("usb: dwc2: Move gadget probe function into platform code")
Reported-by: kbuild test robot <[email protected]>
Tested-by: Marek Vasut <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Minas Harutyunyan <[email protected]>
Link: https://lore.kernel.org/r/f21cb38fecc72a230b86155d94c7e60c9cb66f58.1591690938.git.hminas@synopsys.com
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Minas Harutyunyan authored and gregkh committed Jun 18, 2020
1 parent 5d80219 commit 207324a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 0 additions & 6 deletions drivers/usb/dwc2/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -4920,12 +4920,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
epnum, 0);
}

ret = usb_add_gadget_udc(dev, &hsotg->gadget);
if (ret) {
dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep,
hsotg->ctrl_req);
return ret;
}
dwc2_hsotg_dump(hsotg);

return 0;
Expand Down
11 changes: 11 additions & 0 deletions drivers/usb/dwc2/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,17 @@ static int dwc2_driver_probe(struct platform_device *dev)
if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
dwc2_lowlevel_hw_disable(hsotg);

#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
/* Postponed adding a new gadget to the udc class driver list */
if (hsotg->gadget_enabled) {
retval = usb_add_gadget_udc(hsotg->dev, &hsotg->gadget);
if (retval) {
dwc2_hsotg_remove(hsotg);
goto error_init;
}
}
#endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
return 0;

error_init:
Expand Down

0 comments on commit 207324a

Please sign in to comment.