From patchwork Tue Oct 4 08:42:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 77236 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2097008qgf; Tue, 4 Oct 2016 01:42:56 -0700 (PDT) X-Received: by 10.66.253.7 with SMTP id zw7mr3365192pac.25.1475570576639; Tue, 04 Oct 2016 01:42:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3si41573908pfn.77.2016.10.04.01.42.56; Tue, 04 Oct 2016 01:42:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957AbcJDImy (ORCPT + 27 others); Tue, 4 Oct 2016 04:42:54 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34875 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961AbcJDImv (ORCPT ); Tue, 4 Oct 2016 04:42:51 -0400 Received: by mail-pa0-f49.google.com with SMTP id ik13so17674082pac.2 for ; Tue, 04 Oct 2016 01:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lTwaHG2g21KOwwm29t2EY8/mfe/5HgcjjoY02YAEYeQ=; b=BNTsDyBHXhxD7aA6pr9cq6PpNxhj7My6ICQZUKan8Yk3cPhbefS9MHNdQHFQMSncXW dDMtCnGS15+oaSNhd3I+842tihPxOGGNav/iSioInxm4yauIqkQs5baxcRALrEDtfhSv D+C8ogXx7nE/5zx+FD9pU9mPwVTpMSSAfBMpg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lTwaHG2g21KOwwm29t2EY8/mfe/5HgcjjoY02YAEYeQ=; b=d0ksObIf3qpAh6w7AFY/opwKWHT10EpWI+VCrfv+xRJe/Na2NqEvnwtfIxHY3FBV1N 3N841su0Yw5ZNJW7rb4Ye+4Om5rqjDDh0t+luAlEnnIjgUzUGS0k1fJTLDfsfUIWs6wU eXxDxvK6HjcpeI6RThFBsDTWD9kGTWPZEpjv+2QIZdFrSC1Q5AL8Al84oiqTHtyTcTvs Qjf3Kg5gaJCRCvX2xZEGtqwhMRjK8iUPlScTOhU7trWTLdg72UgLUm0T74v9FepCSdEi ElGH7l8lSIltqzu8ZcId2TLgUwMoEBzThMM2yDjHkL5bXcKNR4AkOO8YF7vLXeYZ8e9M a7pw== X-Gm-Message-State: AA6/9RnLwX1puCED0g+RD3ISDS9WZhHDPe33LWoB4voREKFlUD/y90O8lycU1Tks02P+tiew X-Received: by 10.66.67.51 with SMTP id k19mr3438825pat.55.1475570571255; Tue, 04 Oct 2016 01:42:51 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id p128sm52953419pfg.38.2016.10.04.01.42.49 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Oct 2016 01:42:50 -0700 (PDT) From: Baolin Wang To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, broonie@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [RESEND PATCH v3 1/2] usb: dwc3: gadget: Add disconnect checking when changing function dynamically Date: Tue, 4 Oct 2016 16:42:25 +0800 Message-Id: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1475570367.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When system has stpped the gadget, we should avoid queuing any requests which will cause tranfer failed. Thus adding some disconnect checking to avoid this situation. Signed-off-by: Baolin Wang --- Changes since v2: - Move disconnect checking into dwc3_send_gadget_ep_cmd(). - Rename completion name and issue complete() at one place. - Move completion initialization into dwc3_gadget_init(). Changes since v1: - Split into 2 separate ptaches. - Choose complete mechanism instead of polling. --- drivers/usb/dwc3/gadget.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.7.9.5 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 1783406..ca2ae5b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -241,6 +241,9 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd, int susphy = false; int ret = -EINVAL; + if (!dwc->pullups_connected) + return -ESHUTDOWN; + /* * Synopsys Databook 2.60a states, on section 6.3.2.5.[1-8], that if * we're issuing an endpoint command, we must check if