From patchwork Thu Aug 15 19:18:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11096337 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 F00E214F7 for ; Thu, 15 Aug 2019 19:18:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2E692871A for ; Thu, 15 Aug 2019 19:18:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4AD028924; Thu, 15 Aug 2019 19:18:19 +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 810402871A for ; Thu, 15 Aug 2019 19:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731954AbfHOTSS (ORCPT ); Thu, 15 Aug 2019 15:18:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58948 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731941AbfHOTSS (ORCPT ); Thu, 15 Aug 2019 15:18:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4380D5AFF8; Thu, 15 Aug 2019 19:18:18 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-92.ams2.redhat.com [10.36.117.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 239686266B; Thu, 15 Aug 2019 19:18:16 +0000 (UTC) From: Hans de Goede To: Greg Kroah-Hartman , Guenter Roeck , Heikki Krogerus Cc: Hans de Goede , linux-usb@vger.kernel.org Subject: [PATCH 1/3] usb: typec: tcpm: Use usb_debug_root as root for our debugfs entry Date: Thu, 15 Aug 2019 21:18:13 +0200 Message-Id: <20190815191815.755606-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 15 Aug 2019 19:18:18 +0000 (UTC) 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 Use usb_debug_root as root for our debugfs entry instead of creating our own subdirectory under the debugfs root. Another patch in this series will make the same change to the fusb302 driver, which also uses dev_name() (on the same device) for the debugfs entry name. So we also prefix dev_name() with "tcpm-" here to avoid a name conflict. Signed-off-by: Hans de Goede Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 15abe1d9958f..5241d17c3399 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -571,17 +572,13 @@ static int tcpm_debug_show(struct seq_file *s, void *v) } DEFINE_SHOW_ATTRIBUTE(tcpm_debug); -static struct dentry *rootdir; - static void tcpm_debugfs_init(struct tcpm_port *port) { - mutex_init(&port->logbuffer_lock); - /* /sys/kernel/debug/tcpm/usbcX */ - if (!rootdir) - rootdir = debugfs_create_dir("tcpm", NULL); + char name[NAME_MAX]; - port->dentry = debugfs_create_file(dev_name(port->dev), - S_IFREG | 0444, rootdir, + mutex_init(&port->logbuffer_lock); + snprintf(name, NAME_MAX, "tcpm-%s", dev_name(port->dev)); + port->dentry = debugfs_create_file(name, S_IFREG | 0444, usb_debug_root, port, &tcpm_debug_fops); } @@ -597,10 +594,6 @@ static void tcpm_debugfs_exit(struct tcpm_port *port) mutex_unlock(&port->logbuffer_lock); debugfs_remove(port->dentry); - if (list_empty(&rootdir->d_subdirs)) { - debugfs_remove(rootdir); - rootdir = NULL; - } } #else