From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from buildserver.ru.mvista.com (unknown [85.21.88.6]) by ozlabs.org (Postfix) with ESMTP id 0A37E474C1 for ; Thu, 13 Nov 2008 07:12:19 +1100 (EST) Date: Wed, 12 Nov 2008 23:12:18 +0300 From: Anton Vorontsov To: Alan Stern Subject: Re: [PATCH] usb/fsl_qe_udc: Report disconnect before unbinding Message-ID: <20081112201218.GA5870@oksana.dev.rtsoft.ru> References: <20081112185627.GA17699@oksana.dev.rtsoft.ru> <20081112195916.GA31938@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 In-Reply-To: <20081112195916.GA31938@oksana.dev.rtsoft.ru> Cc: Greg Kroah-Hartman , David Brownell , Li Yang , linux-usb@vger.kernel.org, linuxppc-dev@ozlabs.org Reply-To: avorontsov@ru.mvista.com List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Wed, Nov 12, 2008 at 10:59:16PM +0300, Anton Vorontsov wrote: [...] > > And wouldn't it be better to _skip_ doing this if the gadget wasn't > > connected before? > > Composite framework handles this. If there were no connections, > then the disconnect() is a nop (except the spin lock/unlock pair). > > I'm not sure how the controller driver could tell if there > was a connection or not: it doesn't operate these terms. > What the udc controller knows is: how to report bus reset > and how to receive or transmit the data... It seems I lied. Did you mean something like this patch? diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index c7de671..fd44cf4 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c @@ -2368,6 +2368,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) /* stop usb controller, disable intr */ qe_usb_disable(); + if (udc->usb_state == USB_STATE_DEFAULT) + goto skip_quiesce; + /* in fact, no needed */ udc_controller->usb_state = USB_STATE_ATTACHED; udc_controller->ep0_state = WAIT_FOR_SETUP; @@ -2385,6 +2388,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) /* report disconnect; the driver is already quiesced */ driver->disconnect(&udc_controller->gadget); +skip_quiesce: /* unbind gadget and unhook driver. */ driver->unbind(&udc_controller->gadget); udc_controller->gadget.dev.driver = NULL;