From patchwork Mon Sep 19 11:52:17 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: 76533 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp918483qgf; Mon, 19 Sep 2016 04:53:20 -0700 (PDT) X-Received: by 10.98.148.2 with SMTP id m2mr14360620pfe.129.1474286000015; Mon, 19 Sep 2016 04:53:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 79si63848589pfl.71.2016.09.19.04.53.19; Mon, 19 Sep 2016 04:53:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756037AbcISLxS (ORCPT + 4 others); Mon, 19 Sep 2016 07:53:18 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35949 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbcISLxR (ORCPT ); Mon, 19 Sep 2016 07:53:17 -0400 Received: by mail-pf0-f174.google.com with SMTP id q2so30203447pfj.3 for ; Mon, 19 Sep 2016 04:53:16 -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=KZGVv/pxehjPTS+EddOOyVIHoD1nKWmUi6Ob3NeTAYN7K4VA56pqB0v3sGHPIVo03Y zueDjYWvd0Zy2T5eo3WIWf3NAv+y91veg7ACU24tsjeQeGUjMkwq3UFg/hj1n0r5siss uNhy7n+Soyzh2yJtHr4WQfvkv1O3L8+ZT8EXg= 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=Y9lvxa4GMRiVn7HeJFX74/Jqo+599H3kma4PQDCCUcj8aEyUvsTINM5Hl1fYFy5R4Q HZ6JcGF/Mo6nFwN3pDilLAdSbHyoKvqdJDgbMo0jkEosoRnmKT3HhOhOAr7EqaKPFUs/ l+EFXi/tbKJr280K2NRf3UIGaqVT/MGgJ7zOXhTPz5xau0lOn5bjvCO+mwZM0aGYS/zt Xdk4TtBHRU/obXD6aWkOq9R6G205pEN1+HRlXwNy5FAF8aM+pXSy4VacA+RVmbSDjgFz BIyWmO43Xi9wk1E6ZJ0pfDoT5snYeIOERdjWip4rT4DXeR92wf2J6UUAd2KksKpmtUuy ARmg== X-Gm-Message-State: AE9vXwOjlDMIeuPJKbGpE2Lqmd3HoJHectfrIHXKeyn7QLW2Z0RncDjFjilKsTigVYd5VgoF X-Received: by 10.98.48.4 with SMTP id w4mr15060294pfw.86.1474285996493; Mon, 19 Sep 2016 04:53:16 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id cu2sm31130169pad.18.2016.09.19.04.53.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 04:53:16 -0700 (PDT) From: Baolin Wang To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: broonie@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v3 1/2] usb: dwc3: gadget: Add disconnect checking when changing function dynamically Date: Mon, 19 Sep 2016 19:52:17 +0800 Message-Id: <521625dd7f5e335e2a681ec65ebffc5832207e5f.1474285737.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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