From patchwork Thu Nov 6 06:27:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 40250 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8DE22245A8 for ; Thu, 6 Nov 2014 06:28:28 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id k14sf213064wgh.3 for ; Wed, 05 Nov 2014 22:28:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=ONEhiBec0sajtjmd1OJsP9SLsHx2WGjlc6Vkha+ZzIs=; b=EmHSAWMIPgHEC15oGA1fb284TmSbEBBm2Ig8JvEH0xbmRJVZudRU1aWFFQsx3nT4g2 G2ptluHfS7+H/S2oHZumqpEwqzo/fsa9phZyR4daQZPwleQJh9ejwk54cbGQ2VaKx0z/ 7/Kva4eI59pAO7uY2nO2u4BRiV5KyRVj9AYQ69lzYyQZrnefwrum1BEEVSq33CpAxRog xjkY0lcg4pakr9NrSKjsJZ2Nnq88GZEraRwou/My3CwT7ri8ySZMBLr9o0Nn4GQuKIc3 BYP9jVfuXMx/9p5W/+3jY3kDDBL1ZZyk5poISXrMdQVeDVqGHafizJYlyKJxz+c0HBiB lnNg== X-Gm-Message-State: ALoCoQnQFvX1gaeWqxlaATxOKISSBE57WhgncLcKyUncDo48BmAh/q6ZTSTtGDYdQpzPU9NNNkE0 X-Received: by 10.194.91.180 with SMTP id cf20mr294564wjb.4.1415255307807; Wed, 05 Nov 2014 22:28:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.1 with SMTP id lk1ls39513lac.9.gmail; Wed, 05 Nov 2014 22:28:27 -0800 (PST) X-Received: by 10.112.132.34 with SMTP id or2mr2367941lbb.75.1415255307378; Wed, 05 Nov 2014 22:28:27 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id t13si9723666lal.121.2014.11.05.22.28.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 22:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id s18so1991731lam.41 for ; Wed, 05 Nov 2014 22:28:27 -0800 (PST) X-Received: by 10.112.12.35 with SMTP id v3mr2463186lbb.80.1415255307147; Wed, 05 Nov 2014 22:28:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp2078lbc; Wed, 5 Nov 2014 22:28:26 -0800 (PST) X-Received: by 10.70.36.132 with SMTP id q4mr2526231pdj.8.1415255305561; Wed, 05 Nov 2014 22:28:25 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fp12si1071584pad.23.2014.11.05.22.28.24 for ; Wed, 05 Nov 2014 22:28:25 -0800 (PST) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751133AbaKFG2W (ORCPT + 3 others); Thu, 6 Nov 2014 01:28:22 -0500 Received: from mail-bn1bon0131.outbound.protection.outlook.com ([157.56.111.131]:37317 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751069AbaKFG2W (ORCPT ); Thu, 6 Nov 2014 01:28:22 -0500 Received: from BY2PR03CA009.namprd03.prod.outlook.com (10.255.93.26) by BN1PR0301MB0770.namprd03.prod.outlook.com (25.160.78.152) with Microsoft SMTP Server (TLS) id 15.1.11.14; Thu, 6 Nov 2014 06:28:19 +0000 Received: from BY2FFO11FD006.protection.gbl (10.255.93.4) by BY2PR03CA009.outlook.office365.com (10.255.93.26) with Microsoft SMTP Server (TLS) id 15.1.11.14 via Frontend Transport; Thu, 6 Nov 2014 06:28:18 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD006.mail.protection.outlook.com (10.1.14.127) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Thu, 6 Nov 2014 06:28:17 +0000 Received: from peterchendt.ap.freescale.net ([10.192.185.78]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id sA66SBru023626; Wed, 5 Nov 2014 23:28:15 -0700 From: Peter Chen To: CC: , , , Peter Chen Subject: [PATCH v2 01/17] usb: dwc3: gadget: use udc-core's reset notifier Date: Thu, 6 Nov 2014 14:27:53 +0800 Message-ID: <1415255289-19540-2-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415255289-19540-1-git-send-email-peter.chen@freescale.com> References: <1415255289-19540-1-git-send-email-peter.chen@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(106466001)(104016003)(50986999)(46102003)(87936001)(92566001)(87286001)(107046002)(105606002)(76176999)(2351001)(92726001)(68736004)(77156002)(19580405001)(19580395003)(88136002)(48376002)(93916002)(229853001)(36756003)(62966003)(4396001)(50226001)(84676001)(44976005)(102836001)(89996001)(86362001)(20776003)(97736003)(110136001)(31966008)(50466002)(64706001)(99396003)(104166001)(95666004)(21056001)(33646002)(47776003)(6806004)(120916001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0770; H:tx30smr01.am.freescale.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0770; X-Exchange-Antispam-Report-Test: UriScan:; X-Forefront-PRVS: 0387D64A71 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; X-OriginatorOrg: freescale.com Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Felipe Balbi Replace usb_gadget_driver's disconnect with udc-core's reset notifier at bus reset handler. Signed-off-by: Felipe Balbi Signed-off-by: Peter Chen --- drivers/usb/dwc3/gadget.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 398c12f..f03b136 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2041,6 +2041,17 @@ static void dwc3_resume_gadget(struct dwc3 *dwc) if (dwc->gadget_driver && dwc->gadget_driver->resume) { spin_unlock(&dwc->lock); dwc->gadget_driver->resume(&dwc->gadget); + } +} + +static void dwc3_reset_gadget(struct dwc3 *dwc) +{ + if (!dwc->gadget_driver) + return; + + if (dwc->gadget.speed != USB_SPEED_UNKNOWN) { + spin_unlock(&dwc->lock); + usb_gadget_udc_reset(&dwc->gadget, dwc->gadget_driver); spin_lock(&dwc->lock); } } @@ -2185,11 +2196,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) dwc3_gadget_disconnect_interrupt(dwc); } - /* after reset -> Default State */ - usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); - - if (dwc->gadget.speed != USB_SPEED_UNKNOWN) - dwc3_disconnect_gadget(dwc); + dwc3_reset_gadget(dwc); reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~DWC3_DCTL_TSTCTRL_MASK;