Commit 9f4bc2ed authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

usb: typec: tcpm: Use usb_debug_root as root for our debugfs entry

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.
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20190817184340.64086-1-hdegoede@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6d03c140
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/usb/pd.h> #include <linux/usb/pd.h>
#include <linux/usb/pd_ado.h> #include <linux/usb/pd_ado.h>
#include <linux/usb/pd_bdo.h> #include <linux/usb/pd_bdo.h>
...@@ -571,17 +572,13 @@ static int tcpm_debug_show(struct seq_file *s, void *v) ...@@ -571,17 +572,13 @@ static int tcpm_debug_show(struct seq_file *s, void *v)
} }
DEFINE_SHOW_ATTRIBUTE(tcpm_debug); DEFINE_SHOW_ATTRIBUTE(tcpm_debug);
static struct dentry *rootdir;
static void tcpm_debugfs_init(struct tcpm_port *port) static void tcpm_debugfs_init(struct tcpm_port *port)
{ {
mutex_init(&port->logbuffer_lock); char name[NAME_MAX];
/* /sys/kernel/debug/tcpm/usbcX */
if (!rootdir)
rootdir = debugfs_create_dir("tcpm", NULL);
port->dentry = debugfs_create_file(dev_name(port->dev), mutex_init(&port->logbuffer_lock);
S_IFREG | 0444, rootdir, 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); port, &tcpm_debug_fops);
} }
...@@ -597,10 +594,6 @@ static void tcpm_debugfs_exit(struct tcpm_port *port) ...@@ -597,10 +594,6 @@ static void tcpm_debugfs_exit(struct tcpm_port *port)
mutex_unlock(&port->logbuffer_lock); mutex_unlock(&port->logbuffer_lock);
debugfs_remove(port->dentry); debugfs_remove(port->dentry);
if (list_empty(&rootdir->d_subdirs)) {
debugfs_remove(rootdir);
rootdir = NULL;
}
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment