[v4,2/3] Revert "Revert "usb: gadget: udc: core: Prevent redundant calls to pullup""

Message ID 20230529234816.3720623-2-badhri@google.com
State New
Headers
Series [v4,1/3] Revert "Revert "usb: gadget: udc: core: Invoke usb_gadget_connect only when started"" |

Commit Message

Badhri Jagan Sridharan May 29, 2023, 11:48 p.m. UTC
  This reverts commit 5e1617210aede9f1b91bb9819c93097b6da481f9.

The regression reported in
https://lore.kernel.org/all/ZF4bMptC3Lf2Hnee@gerhold.net/ is being
fixed in
commit 7d7863db7cc0 ("usb: gadget: udc: core: Offload usb_udc_vbus_handler processing").
Hence reverting the revert.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/gadget/udc/core.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Alan Stern May 30, 2023, 12:44 a.m. UTC | #1
On Mon, May 29, 2023 at 11:48:15PM +0000, Badhri Jagan Sridharan wrote:
> This reverts commit 5e1617210aede9f1b91bb9819c93097b6da481f9.
> 
> The regression reported in
> https://lore.kernel.org/all/ZF4bMptC3Lf2Hnee@gerhold.net/ is being
> fixed in
> commit 7d7863db7cc0 ("usb: gadget: udc: core: Offload usb_udc_vbus_handler processing").
> Hence reverting the revert.
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.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 583c339876ab..4641153e9706 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -703,6 +703,9 @@ static int usb_gadget_connect_locked(struct usb_gadget *gadget)
>  		goto out;
>  	}
>  
> +	if (gadget->connected)
> +		goto out;
> +
>  	if (gadget->deactivated || !gadget->udc->started) {
>  		/*
>  		 * If gadget is deactivated we only save new state.

This is silly.  There's no need to make this a separate commit; it 
should be merged in with the preceding patch.  There's no good reason 
for creating a commit that contains a known error.

Alan Stern
  

Patch

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 583c339876ab..4641153e9706 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -703,6 +703,9 @@  static int usb_gadget_connect_locked(struct usb_gadget *gadget)
 		goto out;
 	}
 
+	if (gadget->connected)
+		goto out;
+
 	if (gadget->deactivated || !gadget->udc->started) {
 		/*
 		 * If gadget is deactivated we only save new state.