From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755158AbbCSOur (ORCPT ); Thu, 19 Mar 2015 10:50:47 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:53399 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbbCSOul (ORCPT ); Thu, 19 Mar 2015 10:50:41 -0400 Message-ID: <550AE237.8000404@ti.com> Date: Thu, 19 Mar 2015 16:50:31 +0200 From: Roger Quadros User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Li Jun CC: Peter Chen , , , , , , , , , Subject: Re: [RFC][PATCH 2/9] usb: gadget: add usb_gadget_start/stop() References: <1426686963-11613-1-git-send-email-rogerq@ti.com> <1426686963-11613-3-git-send-email-rogerq@ti.com> <20150319032944.GA2476@shlinux2> <550AA18F.2000106@ti.com> <20150319140859.GA7950@shlinux1.ap.freescale.net> In-Reply-To: <20150319140859.GA7950@shlinux1.ap.freescale.net> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/03/15 16:09, Li Jun wrote: > On Thu, Mar 19, 2015 at 12:14:39PM +0200, Roger Quadros wrote: >> On 19/03/15 05:30, Peter Chen wrote: >>> On Wed, Mar 18, 2015 at 03:55:56PM +0200, Roger Quadros wrote: >>>> The OTG state machine needs a mechanism to start and >>>> stop the gadget controller. Add usb_gadget_start() >>>> and usb_gadget_stop(). >>>> >>>> Signed-off-by: Roger Quadros >>>> --- >>>> drivers/usb/gadget/udc/udc-core.c | 166 +++++++++++++++++++++++++++++++++++--- >>>> include/linux/usb/gadget.h | 3 + >>>> 2 files changed, 158 insertions(+), 11 deletions(-) >>>> >>>> diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c >>>> index 5a81cb0..69b4123 100644 >>>> --- a/drivers/usb/gadget/udc/udc-core.c >>>> +++ b/drivers/usb/gadget/udc/udc-core.c >>>> @@ -35,6 +35,8 @@ >>>> * @dev - the child device to the actual controller >>>> * @gadget - the gadget. For use by the class code >>>> * @list - for use by the udc class driver >>>> + * @running - udc is running >>> >>> Doesn't OTG FSM should know it? >> >> Not really, as the gadget driver might not have been loaded yet or userspace might >> have disabled softconnect when the OTG FSM wants UDC to start. >> >> So only UDC knows if it has really started or not based on this flag. >> > > why this can not be known by check the otg fsm state? i.e. if the device in > b_peripheral or a_peripheral state, udc should had started, isn't it? If gadget function driver (which is different from UDC driver) is not yet loaded then we can't start UDC even if otg fsm is in b_peripheral. Also, if userspace has disabled softconnect we can't start UDC. So, b_peripheral != UDC_started. I've tried to address this issue by adding the checks in usb_gadget_start(). cheers, -roger