From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9045CC77B60 for ; Fri, 28 Apr 2023 17:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346194AbjD1Rcp (ORCPT ); Fri, 28 Apr 2023 13:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbjD1Rcm (ORCPT ); Fri, 28 Apr 2023 13:32:42 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id BB8CB4203 for ; Fri, 28 Apr 2023 10:32:38 -0700 (PDT) Received: (qmail 213655 invoked by uid 1000); 28 Apr 2023 13:32:37 -0400 Date: Fri, 28 Apr 2023 13:32:37 -0400 From: Alan Stern To: Krishna Kurapati PSSNV Cc: Thinh Nguyen , Greg Kroah-Hartman , Geert Uytterhoeven , Colin Ian King , Jiantao Zhang , "Rafael J . Wysocki" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, quic_ppratap@quicinc.com, quic_wcheng@quicinc.com, quic_jackp@quicinc.com, quic_ugoswami@quicinc.com Subject: Re: [PATCH v2 2/2] usb: gadget: udc: Handle gadget_connect failure during bind operation Message-ID: <55ef9051-716d-4aaf-b994-e0beaecc48a3@rowland.harvard.edu> References: <20230328160756.30520-1-quic_kriskura@quicinc.com> <20230328160756.30520-3-quic_kriskura@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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 Alan Stern