From patchwork Tue Oct 2 14:17:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 10623759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86B8815A6 for ; Tue, 2 Oct 2018 14:17:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BE162000A for ; Tue, 2 Oct 2018 14:17:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E83A200E5; Tue, 2 Oct 2018 14:17:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F39C12000A for ; Tue, 2 Oct 2018 14:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbeJBVBe (ORCPT ); Tue, 2 Oct 2018 17:01:34 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:34696 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726293AbeJBVBd (ORCPT ); Tue, 2 Oct 2018 17:01:33 -0400 Received: (qmail 2408 invoked by uid 2102); 2 Oct 2018 10:17:57 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Oct 2018 10:17:57 -0400 Date: Tue, 2 Oct 2018 10:17:57 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: USB list Subject: [PATCH 1/2] USB: gadget core: Issue ->disconnect() callback from usb_gadget_disconnect() Message-ID: MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The gadget documentation doesn't state clearly whether a gadget driver's ->disconnect() callback should be invoked when the D+ pullup is turned off. Some UDC drivers do this and some don't. This patch settles the issue by making the core function usb_gadget_disconnect() issue the callback, so that UDC drivers don't need to worry about it. A description of the new behavior is added to the function's kerneldoc. Also, the patch removes a few superseded callbacks from other core routines. Future patches will remove the ->disconnect() calls from the UDC drivers that make them, as they are now unnecessary. Until all those patches are merged gadget drivers may receive extra ->disconnect() callbacks, but this should be harmless. Signed-off-by: Alan Stern --- [as1874] drivers/usb/gadget/udc/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) Index: usb-4.x/drivers/usb/gadget/udc/core.c =================================================================== --- usb-4.x.orig/drivers/usb/gadget/udc/core.c +++ usb-4.x/drivers/usb/gadget/udc/core.c @@ -672,6 +672,9 @@ EXPORT_SYMBOL_GPL(usb_gadget_connect); * as a disconnect (when a VBUS session is active). Not all systems * support software pullup controls. * + * Following a successful disconnect, invoke the ->disconnect() callback + * for the current gadget driver so that UDC drivers don't need to. + * * Returns zero on success, else negative errno. */ int usb_gadget_disconnect(struct usb_gadget *gadget) @@ -693,8 +696,10 @@ int usb_gadget_disconnect(struct usb_gad } ret = gadget->ops->pullup(gadget, 0); - if (!ret) + if (!ret) { gadget->connected = 0; + gadget->udc->driver->disconnect(gadget); + } out: trace_usb_gadget_disconnect(gadget, ret); @@ -1263,7 +1268,6 @@ static void usb_gadget_remove_driver(str kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); usb_gadget_disconnect(udc->gadget); - udc->driver->disconnect(udc->gadget); udc->driver->unbind(udc->gadget); usb_gadget_udc_stop(udc); @@ -1453,7 +1457,6 @@ static ssize_t soft_connect_store(struct usb_gadget_connect(udc->gadget); } else if (sysfs_streq(buf, "disconnect")) { usb_gadget_disconnect(udc->gadget); - udc->driver->disconnect(udc->gadget); usb_gadget_udc_stop(udc); } else { dev_err(dev, "unsupported command '%s'\n", buf); From patchwork Tue Oct 2 14:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 10623761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2838914BD for ; Tue, 2 Oct 2018 14:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C76020134 for ; Tue, 2 Oct 2018 14:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3558200E5; Tue, 2 Oct 2018 14:18:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A95CE200E5 for ; Tue, 2 Oct 2018 14:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726727AbeJBVCR (ORCPT ); Tue, 2 Oct 2018 17:02:17 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:34716 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726118AbeJBVCR (ORCPT ); Tue, 2 Oct 2018 17:02:17 -0400 Received: (qmail 2420 invoked by uid 2102); 2 Oct 2018 10:18:40 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Oct 2018 10:18:40 -0400 Date: Tue, 2 Oct 2018 10:18:40 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: USB list Subject: [PATCH 2/2] USB: net2280: Remove ->disconnect() callback from net2280_pullup() Message-ID: MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The net2280 UDC driver invokes the gadget driver's ->disconnect() callback routine when the net2280_pullup() routine turns off the D+ pullup. This is now unnecessary, because the gadget core performs the callback on our behalf. This patch removes the unneeded callback. Signed-off-by: Alan Stern --- [as1875] drivers/usb/gadget/udc/net2280.c | 3 --- 1 file changed, 3 deletions(-) Index: usb-4.x/drivers/usb/gadget/udc/net2280.c =================================================================== --- usb-4.x.orig/drivers/usb/gadget/udc/net2280.c +++ usb-4.x/drivers/usb/gadget/udc/net2280.c @@ -1550,9 +1550,6 @@ static int net2280_pullup(struct usb_gad spin_unlock_irqrestore(&dev->lock, flags); - if (!is_on && dev->driver) - dev->driver->disconnect(&dev->gadget); - return 0; }