diff mbox series

[RESEND,2/2] usb: gadget: core: do not try to disconnect gadget if it is not connected

Message ID 20201013092746.10602-2-peter.chen@nxp.com (mailing list archive)
State New, archived
Headers show
Series [RESEND,1/2] usb: gadget: core: change the comment for usb_gadget_connect | expand

Commit Message

Peter Chen Oct. 13, 2020, 9:27 a.m. UTC
Current UDC core connects gadget during the loading gadget flow
(udc_bind_to_driver->usb_udc_connect_control), but for
platforms which do not connect gadget if the VBUS is not there,
they call usb_gadget_disconnect, but the gadget is not connected
at this time, notify disconnecton for the gadget driver is meaningless
at this situation.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/usb/gadget/udc/core.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Peter Chen Oct. 29, 2020, 10:45 a.m. UTC | #1
On Tue, Oct 13, 2020 at 8:01 PM Peter Chen <peter.chen@nxp.com> wrote:
>
> Current UDC core connects gadget during the loading gadget flow
> (udc_bind_to_driver->usb_udc_connect_control), but for
> platforms which do not connect gadget if the VBUS is not there,
> they call usb_gadget_disconnect, but the gadget is not connected
> at this time, notify disconnecton for the gadget driver is meaningless
> at this situation.
>
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> ---
>  drivers/usb/gadget/udc/core.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 215ecbe8b692..8ad4203dea8c 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -672,6 +672,9 @@ int usb_gadget_connect(struct usb_gadget *gadget)
>                 goto out;
>         }
>
> +       if (!gadget->connected)
> +               goto out;
> +
>         if (gadget->deactivated) {
>                 /*
>                  * If gadget is deactivated we only save new state.
> --
> 2.17.1
>

A gentle ping.

Peter
Peter Chen Dec. 1, 2020, 6:45 a.m. UTC | #2
BR,
Peter Chen

On Thu, Oct 29, 2020 at 6:45 PM Peter Chen <hzpeterchen@gmail.com> wrote:
>
> On Tue, Oct 13, 2020 at 8:01 PM Peter Chen <peter.chen@nxp.com> wrote:
> >
> > Current UDC core connects gadget during the loading gadget flow
> > (udc_bind_to_driver->usb_udc_connect_control), but for
> > platforms which do not connect gadget if the VBUS is not there,
> > they call usb_gadget_disconnect, but the gadget is not connected
> > at this time, notify disconnecton for the gadget driver is meaningless
> > at this situation.
> >
> > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > ---
> >  drivers/usb/gadget/udc/core.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index 215ecbe8b692..8ad4203dea8c 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -672,6 +672,9 @@ int usb_gadget_connect(struct usb_gadget *gadget)
> >                 goto out;
> >         }
> >
> > +       if (!gadget->connected)
> > +               goto out;
> > +
> >         if (gadget->deactivated) {
> >                 /*
> >                  * If gadget is deactivated we only save new state.
> > --
> > 2.17.1
> >
>
> A gentle ping.
>

ping again.

Peter
Greg Kroah-Hartman Dec. 29, 2020, 10:17 a.m. UTC | #3
On Tue, Dec 29, 2020 at 01:56:00PM +0800, Peter Chen wrote:
> On Tue, Dec 1, 2020 at 2:45 PM Peter Chen <hzpeterchen@gmail.com> wrote:
> 
> > BR,
> > Peter Chen
> >
> > On Thu, Oct 29, 2020 at 6:45 PM Peter Chen <hzpeterchen@gmail.com> wrote:
> > >
> > > On Tue, Oct 13, 2020 at 8:01 PM Peter Chen <peter.chen@nxp.com> wrote:
> > > >
> > > > Current UDC core connects gadget during the loading gadget flow
> > > > (udc_bind_to_driver->usb_udc_connect_control), but for
> > > > platforms which do not connect gadget if the VBUS is not there,
> > > > they call usb_gadget_disconnect, but the gadget is not connected
> > > > at this time, notify disconnecton for the gadget driver is meaningless
> > > > at this situation.
> > > >
> > > > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > > > ---
> > > >  drivers/usb/gadget/udc/core.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/drivers/usb/gadget/udc/core.c
> > b/drivers/usb/gadget/udc/core.c
> > > > index 215ecbe8b692..8ad4203dea8c 100644
> > > > --- a/drivers/usb/gadget/udc/core.c
> > > > +++ b/drivers/usb/gadget/udc/core.c
> > > > @@ -672,6 +672,9 @@ int usb_gadget_connect(struct usb_gadget *gadget)
> > > >                 goto out;
> > > >         }
> > > >
> > > > +       if (!gadget->connected)
> > > > +               goto out;
> > > > +
> > > >         if (gadget->deactivated) {
> > > >                 /*
> > > >                  * If gadget is deactivated we only save new state.
> > > > --
> > > > 2.17.1
> > > >
> > >
> > > A gentle ping.
> > >
> >
> > ping again.
> >
> > Peter
> >
> 
> Greg, would you please help to catch it up?

Again, can you please resend?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 215ecbe8b692..8ad4203dea8c 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -672,6 +672,9 @@  int usb_gadget_connect(struct usb_gadget *gadget)
 		goto out;
 	}
 
+	if (!gadget->connected)
+		goto out;
+
 	if (gadget->deactivated) {
 		/*
 		 * If gadget is deactivated we only save new state.