From patchwork Tue Aug 7 19:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 10559091 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 AC18314E5 for ; Tue, 7 Aug 2018 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CCA72A136 for ; Tue, 7 Aug 2018 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90D462A869; Tue, 7 Aug 2018 19:24:51 +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 87F752A136 for ; Tue, 7 Aug 2018 19:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389595AbeHGVkk (ORCPT ); Tue, 7 Aug 2018 17:40:40 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:43426 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729922AbeHGVkk (ORCPT ); Tue, 7 Aug 2018 17:40:40 -0400 Received: (qmail 5849 invoked by uid 2102); 7 Aug 2018 15:24:48 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Aug 2018 15:24:48 -0400 Date: Tue, 7 Aug 2018 15:24:48 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Felipe Balbi cc: USB list Subject: Should usb_gadget_disconnect() call driver's ->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 Felipe: The documentation doesn't state whether a gadget driver's ->disconnect() callback will be invoked when usb_gadget_disconnect() runs. Probably the UDC drivers' behavior has changed over the years. In any case, it's likely that various UDC drivers do behave differently. My current feeling is that ->disconnect() should be invoked only when Vbus turns off, but I can't guarantee that all UDCs will do this. How do you feel about documenting this ambiguity as in the patch below? If you think this is okay, I'll submit it formally. Alan Stern --- 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 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,10 @@ EXPORT_SYMBOL_GPL(usb_gadget_connect); * as a disconnect (when a VBUS session is active). Not all systems * support software pullup controls. * + * Whether or not the gadget driver's ->disconnect() callback will be + * invoked is undefined. Gadget drivers should be prepared for either + * possibility. + * * Returns zero on success, else negative errno. */ int usb_gadget_disconnect(struct usb_gadget *gadget)