You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
BACKPORT: usb: gadget: udc: Handle gadget_connect failure during bind operation
In the event, gadget_connect call (which invokes pullup) fails, propagate the error to udc bind operation which inturn sends the error to configfs. The userspace can then retry enumeartion if it chooses to. Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20230510075252.31023-3-quic_kriskura@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit d34f9bafa78da2a561c67d9daf55fc4d1d80edf0 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ usb- next) Bug: 284900975 Change-Id: I43925bafc6ba7b08e8c501502a0fa58ee40e6526 Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com> (cherry picked from commit 8faa860f5594a68e5ecf97bb632e59097da23d14)
This commit is contained in:
committed by
Matthias Männich
parent
fffb0ae9aa
commit
7cc458acf4
@@ -1047,12 +1047,16 @@ EXPORT_SYMBOL_GPL(usb_gadget_set_state);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void usb_udc_connect_control(struct usb_udc *udc)
|
||||
static int usb_udc_connect_control(struct usb_udc *udc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (udc->vbus)
|
||||
usb_gadget_connect(udc->gadget);
|
||||
ret = usb_gadget_connect(udc->gadget);
|
||||
else
|
||||
usb_gadget_disconnect(udc->gadget);
|
||||
ret = usb_gadget_disconnect(udc->gadget);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1507,15 +1511,26 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
|
||||
if (ret)
|
||||
goto err1;
|
||||
ret = usb_gadget_udc_start(udc);
|
||||
if (ret) {
|
||||
driver->unbind(udc->gadget);
|
||||
goto err1;
|
||||
}
|
||||
if (ret)
|
||||
goto err_start;
|
||||
|
||||
usb_gadget_enable_async_callbacks(udc);
|
||||
usb_udc_connect_control(udc);
|
||||
ret = usb_udc_connect_control(udc);
|
||||
if (ret)
|
||||
goto err_connect_control;
|
||||
|
||||
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
|
||||
return 0;
|
||||
|
||||
err_connect_control:
|
||||
usb_gadget_disable_async_callbacks(udc);
|
||||
if (udc->gadget->irq)
|
||||
synchronize_irq(udc->gadget->irq);
|
||||
usb_gadget_udc_stop(udc);
|
||||
|
||||
err_start:
|
||||
driver->unbind(udc->gadget);
|
||||
|
||||
err1:
|
||||
if (ret != -EISNAM)
|
||||
dev_err(&udc->dev, "failed to start %s: %d\n",
|
||||
|
||||
Reference in New Issue
Block a user