Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5085080ybi; Tue, 4 Jun 2019 00:39:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPFW/wkzgMQqN2qhPjKWWHOZif4cRpWzbBLajKtcXXgVC/4OHuiXJ6tY6csS6Ku3H3gWqa X-Received: by 2002:a63:4754:: with SMTP id w20mr33189553pgk.31.1559633987746; Tue, 04 Jun 2019 00:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559633987; cv=none; d=google.com; s=arc-20160816; b=0uCq0Z9e02xHW/2XiAkMPJPDtFigMjdH7NtD5bfZJVUWoz26YGwsv4ySI9AMMDrMaG zlE5MUwiGQK50BSXgA7YQzgQ/i6dGGUBi17xp6g7y1ot2OYshGkdlZuRenV7sJrEgkqS P8RdZ+BPVtWJadubP9hTU2WXvoHDglhhdQwZLOssgYFgUaZJkT5BvOqbFYUViCDh9P16 SrbWuu12k1+FhVKJnODS2zfvV5TDB45DK3hODY9heSNvdjzZ+iSryB/77CwZNS7DMbFQ SPbniias7y5nqRqss6ZpMNi/DTs+k2y6HQ7zFbMYBGwqXnypOQibVhjhW8A5sEBbVmen u6Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4LdxkOF0W8fx8RnjwuhT1Txz32Ho0uHz8bzhvZQgp+k=; b=D6EtWmvK+y13NScPVvEtv6aHoFPARmXJix+WaH/YuSMBIQv/0+AFB57TSk1uHIXGiH SPxWwsY3ueQ527/a+K6mf0caJpMAOHymy8DkyWI58S/EdVKGWQDdeHLBwFk8Ipzdp4Pr QNm/K7jXdWlCGtUG+125CREaZjVhaWNeNDbk5wKx/npaPD3RjFKHwti5VMHQ1SUkCzmd se7nQ687twqgGdQABHFbcudU+2og4yb+0U+7SmNuoK4Eltfnf1me/C7t6RwvghePSeGj EEGPnXrhiG04IyWUrLRlvy6C8IgtAnkF9vaIFRT2lJpueheaGIEVMfwCz/Qi+1HoItbM ir7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DtKXT2B1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j2si22577808pfi.201.2019.06.04.00.39.31; Tue, 04 Jun 2019 00:39:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DtKXT2B1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfFDHhK (ORCPT + 99 others); Tue, 4 Jun 2019 03:37:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726711AbfFDHhJ (ORCPT ); Tue, 4 Jun 2019 03:37:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F2DA249F4; Tue, 4 Jun 2019 07:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559633828; bh=yYjY9dPy0rYXxHJBZ1dR1jEtdGG5VdpSBr1YZrJynDk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DtKXT2B1mmCgfmSocSk422rsl4VwCBPwwgyDUn74Z9p1rd8VASnFg7wZ797DfmPo6 L76rjNkBWerw3wHawBdh2+nIVCt7FIxBYUL7nasWGYXLG+DS/jsLtTzzAxDcigSCqv K1eZzEuWRcwO5TV5GhrOFWs/kPQkxzZSoG+m9z/I= Date: Tue, 4 Jun 2019 09:37:06 +0200 From: Greg Kroah-Hartman To: Chunfeng Yun Cc: Felipe Balbi , Matthias Brugger , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH v4] usb: create usb_debug_root for gadget only Message-ID: <20190604073706.GA25045@kroah.com> References: <1559633647-29040-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1559633647-29040-1-git-send-email-chunfeng.yun@mediatek.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 04, 2019 at 03:34:07PM +0800, Chunfeng Yun wrote: > When CONFIG_USB is not set, and CONFIG_USB_GADGET is set, > there is an issue, e.g.: > > drivers/usb/mtu3/mtu3_debugfs.o: in function 'ssusb_debugfs_create_root': > mtu3_debugfs.c:(.text+0xba3): undefined reference to 'usb_debug_root' > > usb_debug_root is currently only built when host is supported > (CONFIG_USB is set), for convenience, we also want it created when > gadget only is enabled, this patch try to support it. > > Reported-by: Randy Dunlap > Signed-off-by: Chunfeng Yun > --- > v4: > move common API into common.c suggested by Felipe > > v3: > 1. still create usb_debug_root for gadget only > 2. abandon mtu3's change > 3. drop acked-by Randy > > v2(resend): add acked-by Randy > > v1: fix mtu3's build error, replace usb_debug_root by NULL; > --- > drivers/usb/common/common.c | 26 ++++++++++++++++++++++++++ > drivers/usb/core/usb.c | 16 ++++------------ > drivers/usb/gadget/udc/core.c | 3 +++ > include/linux/usb.h | 2 ++ > 4 files changed, 35 insertions(+), 12 deletions(-) > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c > index 18f5dcf58b0d..c52e9c9f58ec 100644 > --- a/drivers/usb/common/common.c > +++ b/drivers/usb/common/common.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > static const char *const ep_type_names[] = { > [USB_ENDPOINT_XFER_CONTROL] = "ctrl", > @@ -139,6 +140,31 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev) > } > EXPORT_SYMBOL_GPL(usb_get_dr_mode); > > +struct dentry *usb_debug_root; > +EXPORT_SYMBOL_GPL(usb_debug_root); > + > +static atomic_t usb_debug_root_refcnt = ATOMIC_INIT(0); Ick, no. > + > +struct dentry *usb_debugfs_init(void) > +{ > + if (!usb_debug_root) > + usb_debug_root = debugfs_create_dir("usb", NULL); > + > + atomic_inc(&usb_debug_root_refcnt); > + > + return usb_debug_root; > +} > +EXPORT_SYMBOL_GPL(usb_debugfs_init); > + > +void usb_debugfs_cleanup(void) > +{ > + if (atomic_dec_and_test(&usb_debug_root_refcnt)) { > + debugfs_remove_recursive(usb_debug_root); > + usb_debug_root = NULL; > + } > +} > +EXPORT_SYMBOL_GPL(usb_debugfs_cleanup); Only remove the debugfs subdir if the usbcore module is removed. Create the debugfs subdir when the usbcore module is loaded. No need for any reference counting of any sort at all. No need to overthink this :) thanks, greg k-h