From patchwork Mon Oct 23 21:32:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 116884 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5100913qgn; Mon, 23 Oct 2017 14:33:01 -0700 (PDT) X-Received: by 10.98.87.138 with SMTP id i10mr14502373pfj.185.1508794381179; Mon, 23 Oct 2017 14:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508794381; cv=none; d=google.com; s=arc-20160816; b=yeEwp+MGHOK/E11+UGrPBePxscUZab5b7GiD35bUyD/OnPYEkxBueRxk+jr2XxJliJ 8zPub/SPMO41/EDPLv7C8vVvoj7XDBQvOMQW9gkfRFToaOIZV+4AlfaAE1V6MEGAnrFf /xHkAZQaT12J8yJJc7MCy9iD3waw/ArrWZzjzmUZQ93RX3ehJ9DvmdzfjYtWqGEryj/v KLa/4AG+tfGTHtg0Kyr5F9IJCwtu8FGl+gZOrdieulSN7ea8BXSvQrK9b1ppWfKnlQK/ zgJee2aZUL9/YHNciwBNlvrEf3jhn3lbhseQo0DMpoYdU98T9lIY9MPglJs2eFLNEUdK Z2CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=RHII1PIYyvq98bJLh+8Ac6YUknGTnCO0rmisebW49IjHlPR/14rrpGVm6Z6f6ZMHin AT4uQuckR4g2JEHion9M/EkjjejWsRFlaGRM4LwDyKsU4ETD3QDmOQhyfC5juMgXNWJi UiMxY0oZZECXG9iObYXPYtasP3vbMIt0pDmZf56XTK/aPcyI6kN1Dcjhmg6ZEGs8Pxtc eXJ0IyLclYFCdw/dUao9+cuYCxoxcjhmhzjb9ze3U866F3DhSWw4lhrS90farsJvEwmT ZNf/NDRc9bvHvoNxI8e2tw3i0UAny/7kHtj2SYAeY3Jt+tK3XaQkgJArF3GJK4+UWaVP kJpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuxNIjBw; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y1sor2339220pfl.26.2017.10.23.14.33.01 for (Google Transport Security); Mon, 23 Oct 2017 14:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fuxNIjBw; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=fuxNIjBwOkBU2FLSPrfNKal3WJpSiv62eVWnKDZheCWJyAt2lKFUEVKGao6uJsxw2e YD2fhFX8EuSm+UFtX2ZfG9dDU+CM7JhwmE249MVYe7HBQtFeL+AEDzpHOGU0APxxlEn3 4fMCJ3WIPHWJu69QwbQX7BwnZkyHo4FVgrNkc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=31oYxj9j368ELcZ5rGSGpd+VxzOrOYW97h6rNwsG6c8=; b=sfTMuhVl31HfQjscSuVCP7wGLfE7dQ1UqGiW9O1Lr/t1/86qEjvVAx0j1DOFVM9OSQ 1pLz45Hd9RbBanAy8QfPVTtBr1T53D1kqC9AfoSZMJn+8AkiDucTy5iTS2nsN2H444Gx 6Udf3xVXwys8VZVCNbxlxnKi9zqeJ2wa0/O2vp7H000uhlWxNkD0niyruUdB5hOlK9c9 rOBdzUfYJYOtMCmN5vR3tgjvH2zPRylpmh3M83jgy+hF3LzYJvSYuYvIRg+FSPCBAKhi mrKgpWZonQDdUyR+6695rL/r31U8040W56hhozkbFnLyuBKDWoljTqE+AnUinOvCe5AP qMhA== X-Gm-Message-State: AMCzsaVlN3FMEkbCckfobW+Y+HmUk0NVQ1nfFBZ5IpYnh2S4FD8YwbUO 8M2Vz8YuxTRRZmAtKVM3QW4sUPIc X-Google-Smtp-Source: ABhQp+Q/8785Qc/sn5/s+N2Mz9OMzmbs4alTH8xB2bPeEZiE75w6odU1pTVuKhrbmNCfCiyYcjjmcg== X-Received: by 10.98.194.86 with SMTP id l83mr14101015pfg.314.1508794380856; Mon, 23 Oct 2017 14:33:00 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id f11sm4518766pfd.82.2017.10.23.14.32.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 14:32:59 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH 3/3 v2] usb: dwc2: Fix UDC state tracking Date: Mon, 23 Oct 2017 14:32:50 -0700 Message-Id: <1508794370-29982-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508794370-29982-1-git-send-email-john.stultz@linaro.org> References: <1508794370-29982-1-git-send-email-john.stultz@linaro.org> It has been noticed that the dwc2 udc state reporting doesn't seem to work (at least on HiKey boards). Where after the initial setup, the sysfs /sys/class/udc/f72c0000.usb/state file would report "configured" no matter the state of the OTG port. This patch adds a call so that we report to the UDC layer when the gadget device is disconnected. This patch does depend on the previous patch ("usb: dwc2: Improve gadget state disconnection handling") in this patch set in order to properly work. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Tested by: Minas Harutyunyan Reported-by: Amit Pundir Signed-off-by: John Stultz --- drivers/usb/dwc2/gadget.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 Acked-by: Minas Harutyunyan Tested-by: Minas Harutyunyan diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 7fd0e38..603c216 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3202,6 +3202,8 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) call_gadget(hsotg, disconnect); hsotg->lx_state = DWC2_L3; + + usb_gadget_set_state(&hsotg->gadget, USB_STATE_NOTATTACHED); } /**