[v2,2/2] usb: gadget: udc: Handle gadget_connect failure during bind operation

Message ID 20230328160756.30520-3-quic_kriskura@quicinc.com
State New
Headers
Series Handle core soft reset failure in pullup |

Commit Message

Krishna Kurapati March 28, 2023, 4:07 p.m. UTC
  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>
---
 drivers/usb/gadget/udc/core.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
  

Comments

Krishna Kurapati April 26, 2023, 1:17 a.m. UTC | #1
Hi Alan, Geert,

  Can you help review and provide comments/approval on the following patch.

Regards,
Krishna,

On 3/28/2023 9:37 PM, Krishna Kurapati wrote:
> 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>
> ---
>   drivers/usb/gadget/udc/core.c | 20 ++++++++++++++++----
>   1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 23b0629a8774..975205a1853f 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -1051,12 +1051,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;
>   }
>   
>   /**
> @@ -1500,11 +1504,19 @@ static int gadget_bind_driver(struct device *dev)
>   	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 (gadget->irq)
> +		synchronize_irq(gadget->irq);
> +	usb_gadget_udc_stop(udc);
> +
>    err_start:
>   	driver->unbind(udc->gadget);
>
  
Geert Uytterhoeven April 26, 2023, 9:18 a.m. UTC | #2
Hi Krishna,

On Wed, Apr 26, 2023 at 3:17 AM Krishna Kurapati PSSNV
<quic_kriskura@quicinc.com> wrote:
> Hi Alan, Geert,
>
>   Can you help review and provide comments/approval on the following patch.

I don't know why you are addressing me, as I never touched the affected
file, am not listed as its maintainer, and don't know much about USB UDC.

Gr{oetje,eeting}s,

                        Geert
  
Geert Uytterhoeven April 27, 2023, 9:09 a.m. UTC | #3
Hi Krishna,

CC Joe and lkml

On Thu, Apr 27, 2023 at 10:44 AM Krishna Kurapati PSSNV
<quic_kriskura@quicinc.com> wrote:
> On 4/27/2023 1:23 PM, Geert Uytterhoeven wrote:
> > On Thu, Apr 27, 2023 at 5:49 AM Krishna Kurapati PSSNV
> > <quic_kriskura@quicinc.com> wrote:
> >> On 4/26/2023 2:48 PM, Geert Uytterhoeven wrote:
> >>> On Wed, Apr 26, 2023 at 3:17 AM Krishna Kurapati PSSNV
> >>> <quic_kriskura@quicinc.com> wrote:
> >>>> Hi Alan, Geert,
> >>>>
> >>>>     Can you help review and provide comments/approval on the following patch.
> >>>
> >>> I don't know why you are addressing me, as I never touched the affected
> >>> file, am not listed as its maintainer, and don't know much about USB UDC.
> >
> >>    Apologies. I must have caused some confusion because of same name. I
> >> must have specified clearly whom I was referring to.
> >>
> >> I CC'd and was referring to Geert Uytterhoeven <geert+renesas@glider.be>
> >> for comments.
> >
> > That's actually me, too ;-)
> >
> >> As per the output of get_maintainer.pl
> >>
> >> ./scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
> >>
> >> Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> >> SUBSYSTEM,commit_signer:6/6=100%,authored:1/6=17%,removed_lines:2/26=8%)
> >> Alan Stern <stern@rowland.harvard.edu>
> >> (commit_signer:4/6=67%,authored:3/6=50%,added_lines:36/45=80%,removed_lines:17/26=65%)
> >> TaoXue <xuetao09@huawei.com> (commit_signer:1/6=17%)
> >> "Rafael J. Wysocki" <rafael@kernel.org> (commit_signer:1/6=17%)
> >> Geert Uytterhoeven <geert+renesas@glider.be> (commit_signer:1/6=17%)
> >> Colin Ian King <colin.i.king@gmail.com> (authored:1/6=17%)
> >> Jiantao Zhang <water.zhangjiantao@huawei.com>
> >> (authored:1/6=17%,added_lines:6/45=13%,removed_lines:6/26=23%)
> >
> > Interesting, I don't see me listed when running that command (on v6.3 and
> > next-20230425), and I never authored any change to that file.
> > What is the tree (commit sha1) you are running ./scripts/get_maintainer.pl on?
>
> I checked it on linux-next a couple of weeks back and it showed me this.
> But when I synced latest linux kernel, it didn't show it today 😅
> Not sure, what is the diff here.

Interesting:

    $ git checkout next-20230425
    Updating files: 100% (7386/7386), done.
    Previous HEAD position was 198925fae644b009 Add linux-next
specific files for 20230329
    HEAD is now at f600e0bbde8562a0 Add linux-next specific files for 20230425
    $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
    Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
SUBSYSTEM,commit_signer:11/11=100%,authored:3/11=27%,removed_lines:5/73=7%)
    Alan Stern <stern@rowland.harvard.edu>
(commit_signer:4/11=36%,authored:3/11=27%,added_lines:36/182=20%,removed_lines:17/73=23%)
    Badhri Jagan Sridharan <badhri@google.com>
(commit_signer:2/11=18%,authored:2/11=18%,added_lines:107/182=59%,removed_lines:44/73=60%)
    Elson Roy Serrao <quic_eserrao@quicinc.com>
(commit_signer:1/11=9%,added_lines:27/182=15%)
    Sebastian Reichel <sre@kernel.org> (commit_signer:1/11=9%)
    Colin Ian King <colin.i.king@gmail.com> (authored:1/11=9%)
    Jiantao Zhang <water.zhangjiantao@huawei.com>
(authored:1/11=9%,removed_lines:6/73=8%)
    linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
    linux-kernel@vger.kernel.org (open list)
    $ git checkout next-20230329
    Updating files: 100% (7386/7386), done.
    Previous HEAD position was f600e0bbde8562a0 Add linux-next
specific files for 20230425
    HEAD is now at 198925fae644b009 Add linux-next specific files for 20230329
    $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
    Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
SUBSYSTEM,commit_signer:8/8=100%,authored:3/8=38%,added_lines:5/48=10%,removed_lines:5/29=17%)
    Alan Stern <stern@rowland.harvard.edu>
(commit_signer:3/8=50%,authored:3/8=38%,added_lines:36/48=75%,removed_lines:17/29=59%)
    Geert Uytterhoeven <geert+renesas@glider.be> (commit_signer:1/8=12%)
    Sebastian Reichel <sre@kernel.org> (commit_signer:1/8=12%)
    Heikki Krogerus <heikki.krogerus@linux.intel.com> (commit_signer:1/8=12%)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I, Sebastian, and Heikki never touched this file...

     Jiantao Zhang <water.zhangjiantao@huawei.com>
(authored:1/8=12%,added_lines:6/48=12%,removed_lines:6/29=21%)
    Colin Ian King <colin.i.king@gmail.com> (authored:1/8=12%)
    linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
    linux-kernel@vger.kernel.org (open list)
    $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
    Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
SUBSYSTEM,commit_signer:8/8=100%,authored:3/8=38%,added_lines:5/48=10%,removed_lines:5/29=17%)
    Alan Stern <stern@rowland.harvard.edu>
(commit_signer:4/8=50%,authored:3/8=38%,added_lines:36/48=75%,removed_lines:17/29=59%)
    "Rafael J. Wysocki" <rafael@kernel.org> (commit_signer:1/8=12%)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Heikki and I are gone, but Rafael is new and also hasn't touched this file?

    Colin Ian King <colin.i.king@gmail.com>
(commit_signer:1/8=12%,authored:1/8=12%)
    Sebastian Reichel <sre@kernel.org> (commit_signer:1/8=12%)
    Jiantao Zhang <water.zhangjiantao@huawei.com>
(authored:1/8=12%,added_lines:6/48=12%,removed_lines:6/29=21%)
    linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
    linux-kernel@vger.kernel.org (open list)

You can see the differences when running the following multiple times:

    $ diff <(scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c)
<(scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c)

Looks like scripts/get_maintainer.pl (a) shows wrong committers (they
did provide other e.g. Reviewed-by tags), and (b) is not deterministic?

Thanks!

Gr{oetje,eeting}s,

                        Geert
  
Andreas Schwab April 27, 2023, 9:56 a.m. UTC | #4
On Apr 27 2023, Geert Uytterhoeven wrote:

>     $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
>     Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> SUBSYSTEM,commit_signer:8/8=100%,authored:3/8=38%,added_lines:5/48=10%,removed_lines:5/29=17%)
>     Alan Stern <stern@rowland.harvard.edu>
> (commit_signer:3/8=50%,authored:3/8=38%,added_lines:36/48=75%,removed_lines:17/29=59%)
>     Geert Uytterhoeven <geert+renesas@glider.be> (commit_signer:1/8=12%)
>     Sebastian Reichel <sre@kernel.org> (commit_signer:1/8=12%)
>     Heikki Krogerus <heikki.krogerus@linux.intel.com> (commit_signer:1/8=12%)
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> I, Sebastian, and Heikki never touched this file...

If you look at 'git log drivers/usb/gadget/udc/core.c', you see commits
touching scripts/get_maintainer.pl.
  
Andreas Schwab April 27, 2023, 10:01 a.m. UTC | #5
Please ignore that, typo on my side.
  
Alan Stern April 28, 2023, 5:32 p.m. UTC | #6
On Wed, Apr 26, 2023 at 06:47:13AM +0530, Krishna Kurapati PSSNV wrote:
> Hi Alan, Geert,
> 
>  Can you help review and provide comments/approval on the following patch.
> 
> Regards,
> Krishna,

Sorry this took so long to review; I've been quite busy.

The patch is good except for one stylistic thing...

> On 3/28/2023 9:37 PM, Krishna Kurapati wrote:
> > 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>
> > ---
> >   drivers/usb/gadget/udc/core.c | 20 ++++++++++++++++----
> >   1 file changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index 23b0629a8774..975205a1853f 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -1051,12 +1051,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;
> >   }
> >   /**
> > @@ -1500,11 +1504,19 @@ static int gadget_bind_driver(struct device *dev)
> >   	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:

For consistency with the other error-handling statement labels in this 
routine, there should be a blank line immediately before this label.

> > +	usb_gadget_disable_async_callbacks(udc);
> > +	if (gadget->irq)
> > +		synchronize_irq(gadget->irq);
> > +	usb_gadget_udc_stop(udc);
> > +
> >    err_start:
> >   	driver->unbind(udc->gadget);

Everything else looks okay.

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern
  
Joe Perches April 28, 2023, 9:58 p.m. UTC | #7
On Thu, 2023-04-27 at 11:09 +0200, Geert Uytterhoeven wrote:
> Hi Krishna,
> 
> CC Joe and lkml

get_maintainer is sometimes non deterministic.

When adding maintainers from git commit logs (and btw, it's
not just nominal maintainers, it's any signers), if the
same number of signature names are read from the commit logs
the selection of the listed entries _is_ random.

see: https://lore.kernel.org/lkml/1499984554.4457.64.camel@perches.com/

> 
> On Thu, Apr 27, 2023 at 10:44 AM Krishna Kurapati PSSNV
> <quic_kriskura@quicinc.com> wrote:
> > On 4/27/2023 1:23 PM, Geert Uytterhoeven wrote:
> > > On Thu, Apr 27, 2023 at 5:49 AM Krishna Kurapati PSSNV
> > > <quic_kriskura@quicinc.com> wrote:
> > > > On 4/26/2023 2:48 PM, Geert Uytterhoeven wrote:
> > > > > On Wed, Apr 26, 2023 at 3:17 AM Krishna Kurapati PSSNV to l
> > > > > <quic_kriskura@quicinc.com> wrote:
> > > > > > Hi Alan, Geert,
> > > > > > 
> > > > > >     Can you help review and provide comments/approval on the following patch.
> > > > > 
> > > > > I don't know why you are addressing me, as I never touched the affected
> > > > > file, am not listed as its maintainer, and don't know much about USB UDC.
> > > 
> > > >    Apologies. I must have caused some confusion because of same name. I
> > > > must have specified clearly whom I was referring to.
> > > > 
> > > > I CC'd and was referring to Geert Uytterhoeven <geert+renesas@glider.be>
> > > > for comments.
> > > 
> > > That's actually me, too ;-)
> > > 
> > > > As per the output of get_maintainer.pl
> > > > 
> > > > ./scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
> > > > 
> > > > Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> > > > SUBSYSTEM,commit_signer:6/6=100%,authored:1/6=17%,removed_lines:2/26=8%)
> > > > Alan Stern <stern@rowland.harvard.edu>
> > > > (commit_signer:4/6=67%,authored:3/6=50%,added_lines:36/45=80%,removed_lines:17/26=65%)
> > > > TaoXue <xuetao09@huawei.com> (commit_signer:1/6=17%)
> > > > "Rafael J. Wysocki" <rafael@kernel.org> (commit_signer:1/6=17%)
> > > > Geert Uytterhoeven <geert+renesas@glider.be> (commit_signer:1/6=17%)
> > > > Colin Ian King <colin.i.king@gmail.com> (authored:1/6=17%)
> > > > Jiantao Zhang <water.zhangjiantao@huawei.com>
> > > > (authored:1/6=17%,added_lines:6/45=13%,removed_lines:6/26=23%)
> > > 
> > > Interesting, I don't see me listed when running that command (on v6.3 and
> > > next-20230425), and I never authored any change to that file.
> > > What is the tree (commit sha1) you are running ./scripts/get_maintainer.pl on?
> > 
> > I checked it on linux-next a couple of weeks back and it showed me this.
> > But when I synced latest linux kernel, it didn't show it today 😅
> > Not sure, what is the diff here.
> 
> Interesting:
> 
>     $ git checkout next-20230425
>     Updating files: 100% (7386/7386), done.
>     Previous HEAD position was 198925fae644b009 Add linux-next
> specific files for 20230329
>     HEAD is now at f600e0bbde8562a0 Add linux-next specific files for 20230425
>     $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
>     Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> SUBSYSTEM,commit_signer:11/11=100%,authored:3/11=27%,removed_lines:5/73=7%)
>     Alan Stern <stern@rowland.harvard.edu>
> (commit_signer:4/11=36%,authored:3/11=27%,added_lines:36/182=20%,removed_lines:17/73=23%)
>     Badhri Jagan Sridharan <badhri@google.com>
> (commit_signer:2/11=18%,authored:2/11=18%,added_lines:107/182=59%,removed_lines:44/73=60%)
>     Elson Roy Serrao <quic_eserrao@quicinc.com>
> (commit_signer:1/11=9%,added_lines:27/182=15%)
>     Sebastian Reichel <sre@kernel.org> (commit_signer:1/11=9%)
>     Colin Ian King <colin.i.king@gmail.com> (authored:1/11=9%)
>     Jiantao Zhang <water.zhangjiantao@huawei.com>
> (authored:1/11=9%,removed_lines:6/73=8%)
>     linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
>     linux-kernel@vger.kernel.org (open list)
>     $ git checkout next-20230329
>     Updating files: 100% (7386/7386), done.
>     Previous HEAD position was f600e0bbde8562a0 Add linux-next
> specific files for 20230425
>     HEAD is now at 198925fae644b009 Add linux-next specific files for 20230329
>     $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
>     Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> SUBSYSTEM,commit_signer:8/8=100%,authored:3/8=38%,added_lines:5/48=10%,removed_lines:5/29=17%)
>     Alan Stern <stern@rowland.harvard.edu>
> (commit_signer:3/8=50%,authored:3/8=38%,added_lines:36/48=75%,removed_lines:17/29=59%)
>     Geert Uytterhoeven <geert+renesas@glider.be> (commit_signer:1/8=12%)
>     Sebastian Reichel <sre@kernel.org> (commit_signer:1/8=12%)
>     Heikki Krogerus <heikki.krogerus@linux.intel.com> (commit_signer:1/8=12%)
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> I, Sebastian, and Heikki never touched this file...
> 
>      Jiantao Zhang <water.zhangjiantao@huawei.com>
> (authored:1/8=12%,added_lines:6/48=12%,removed_lines:6/29=21%)
>     Colin Ian King <colin.i.king@gmail.com> (authored:1/8=12%)
>     linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
>     linux-kernel@vger.kernel.org (open list)
>     $ scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c
>     Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:USB
> SUBSYSTEM,commit_signer:8/8=100%,authored:3/8=38%,added_lines:5/48=10%,removed_lines:5/29=17%)
>     Alan Stern <stern@rowland.harvard.edu>
> (commit_signer:4/8=50%,authored:3/8=38%,added_lines:36/48=75%,removed_lines:17/29=59%)
>     "Rafael J. Wysocki" <rafael@kernel.org> (commit_signer:1/8=12%)
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Heikki and I are gone, but Rafael is new and also hasn't touched this file?
> 
>     Colin Ian King <colin.i.king@gmail.com>
> (commit_signer:1/8=12%,authored:1/8=12%)
>     Sebastian Reichel <sre@kernel.org> (commit_signer:1/8=12%)
>     Jiantao Zhang <water.zhangjiantao@huawei.com>
> (authored:1/8=12%,added_lines:6/48=12%,removed_lines:6/29=21%)
>     linux-usb@vger.kernel.org (open list:USB SUBSYSTEM)
>     linux-kernel@vger.kernel.org (open list)
> 
> You can see the differences when running the following multiple times:
> 
>     $ diff <(scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c)
> <(scripts/get_maintainer.pl drivers/usb/gadget/udc/core.c)
> 
> Looks like scripts/get_maintainer.pl (a) shows wrong committers (they
> did provide other e.g. Reviewed-by tags), and (b) is not deterministic?
> 
> Thanks!
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
>
  

Patch

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 23b0629a8774..975205a1853f 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1051,12 +1051,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;
 }
 
 /**
@@ -1500,11 +1504,19 @@  static int gadget_bind_driver(struct device *dev)
 	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 (gadget->irq)
+		synchronize_irq(gadget->irq);
+	usb_gadget_udc_stop(udc);
+
  err_start:
 	driver->unbind(udc->gadget);