From patchwork Fri Aug 10 19:32:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 10563107 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 A26D81515 for ; Fri, 10 Aug 2018 19:32:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914432B377 for ; Fri, 10 Aug 2018 19:32:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A4FB2B575; Fri, 10 Aug 2018 19:32:27 +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 06E432B377 for ; Fri, 10 Aug 2018 19:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727035AbeHJWDj (ORCPT ); Fri, 10 Aug 2018 18:03:39 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:58398 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726446AbeHJWDj (ORCPT ); Fri, 10 Aug 2018 18:03:39 -0400 Received: (qmail 5030 invoked by uid 2102); 10 Aug 2018 15:32:25 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 10 Aug 2018 15:32:25 -0400 Date: Fri, 10 Aug 2018 15:32:25 -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 Fri Aug 10 19:32:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 10563109 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 6ABFD1515 for ; Fri, 10 Aug 2018 19:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58F442B377 for ; Fri, 10 Aug 2018 19:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4983C2B575; Fri, 10 Aug 2018 19:32:33 +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 DAE2C2B377 for ; Fri, 10 Aug 2018 19:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727087AbeHJWDp (ORCPT ); Fri, 10 Aug 2018 18:03:45 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:58402 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726446AbeHJWDo (ORCPT ); Fri, 10 Aug 2018 18:03:44 -0400 Received: (qmail 5034 invoked by uid 2102); 10 Aug 2018 15:32:31 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 10 Aug 2018 15:32:31 -0400 Date: Fri, 10 Aug 2018 15:32:31 -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; }