Skip to contentSkip to conversation

USB: host: isp116x: remove dentry pointer for debugfs

PATCH In review Greg Kroah-Hartman 3 participants 11 messages Feb 16, 2021 – Mar 2, 2021

Subsystems (5)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 2/6 USB: host: isp1362: remove dentry pointer for debugfs

In reply to Greg Kroah-Hartman

There is no need to keep the dentry pointer around for the created debugfs file, as it is only needed when removing it from the system. When it is to be removed, ask debugfs itself for the pointer, to save on storage and make things a bit simpler.

---
 drivers/usb/host/isp1362-hcd.c | 8 +++-----
 drivers/usb/host/isp1362.h     | 1 -
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/usb/host/isp1362-hcd.c +3 -5
index 2cecb36d241b..d8610ce8f2ec 100644
@@ -2164,15 +2164,13 @@ DEFINE_SHOW_ATTRIBUTE(isp1362);
 /* expect just one isp1362_hcd per system */
 static void create_debug_file(struct isp1362_hcd *isp1362_hcd)
 {
-	isp1362_hcd->debug_file = debugfs_create_file("isp1362", S_IRUGO,
-						      usb_debug_root,
-						      isp1362_hcd,
-						      &isp1362_fops);
+	debugfs_create_file("isp1362", S_IRUGO, usb_debug_root, isp1362_hcd,
+			    &isp1362_fops);
 }
 
 static void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
 {
-	debugfs_remove(isp1362_hcd->debug_file);
+	debugfs_remove(debugfs_lookup("isp1362", usb_debug_root));
 }
 
 /*-------------------------------------------------------------------------*/
drivers/usb/host/isp1362.h +0 -1
index 208705b08d37..74ca4be24723 100644
@@ -435,7 +435,6 @@ struct isp1362_hcd {
 
 	struct isp1362_platform_data *board;
 
-	struct dentry		*debug_file;
 	unsigned long		stat1, stat2, stat4, stat8, stat16;
 
 	/* HC registers */
Signature · 1 line
2.30.1
author maintainer
#2 lore raw

PATCH 3/6 USB: host: sl811: remove dentry pointer for debugfs

In reply to Greg Kroah-Hartman

There is no need to keep the dentry pointer around for the created debugfs file, as it is only needed when removing it from the system. When it is to be removed, ask debugfs itself for the pointer, to save on storage and make things a bit simpler.

---
 drivers/usb/host/sl811-hcd.c | 7 +++----
 drivers/usb/host/sl811.h     | 1 -
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/usb/host/sl811-hcd.c +3 -4
index 115ced0d93e1..d49fb656d34b 100644
@@ -1496,14 +1496,13 @@ DEFINE_SHOW_ATTRIBUTE(sl811h_debug);
 /* expect just one sl811 per system */
 static void create_debug_file(struct sl811 *sl811)
 {
-	sl811->debug_file = debugfs_create_file("sl811h", S_IRUGO,
-						usb_debug_root, sl811,
-						&sl811h_debug_fops);
+	debugfs_create_file("sl811h", S_IRUGO, usb_debug_root, sl811,
+			    &sl811h_debug_fops);
 }
 
 static void remove_debug_file(struct sl811 *sl811)
 {
-	debugfs_remove(sl811->debug_file);
+	debugfs_remove(debugfs_lookup("sl811h", usb_debug_root));
 }
 
 /*-------------------------------------------------------------------------*/
drivers/usb/host/sl811.h +0 -1
index 2abe51a5db44..ba8c9aa7dee8 100644
@@ -123,7 +123,6 @@ struct sl811 {
 	void __iomem		*addr_reg;
 	void __iomem		*data_reg;
 	struct sl811_platform_data	*board;
-	struct dentry 		*debug_file;
 
 	unsigned long		stat_insrmv;
 	unsigned long		stat_wake;
Signature · 1 line
2.30.1
author maintainer
#3 lore raw

PATCH 4/6 USB: host: uhci: remove dentry pointer for debugfs

In reply to Greg Kroah-Hartman

There is no need to keep the dentry pointer around for the created debugfs file, as it is only needed when removing it from the system. When it is to be removed, ask debugfs itself for the pointer, to save on storage and make things a bit simpler.

And, no one noticed that a __maybe_unused dentry * in uhci_start() really was unused, so remove that as it's obviously not needed, and hasn't been for quite some time.

---
 drivers/usb/host/uhci-hcd.c | 12 +++++-------
 drivers/usb/host/uhci-hcd.h |  4 ----
 2 files changed, 5 insertions(+), 11 deletions(-)
drivers/usb/host/uhci-hcd.c +5 -7
index 03bc59755123..d90b869f5f40 100644
@@ -536,7 +536,8 @@ static void release_uhci(struct uhci_hcd *uhci)
 	uhci->is_initialized = 0;
 	spin_unlock_irq(&uhci->lock);
 
-	debugfs_remove(uhci->dentry);
+	debugfs_remove(debugfs_lookup(uhci_to_hcd(uhci)->self.bus_name,
+				      uhci_debugfs_root));
 
 	for (i = 0; i < UHCI_NUM_SKELQH; i++)
 		uhci_free_qh(uhci, uhci->skelqh[i]);
@@ -577,7 +578,6 @@ static int uhci_start(struct usb_hcd *hcd)
 	struct uhci_hcd *uhci = hcd_to_uhci(hcd);
 	int retval = -EBUSY;
 	int i;
-	struct dentry __maybe_unused *dentry;
 
 	hcd->uses_new_polling = 1;
 	/* Accept arbitrarily long scatter-gather lists */
@@ -590,10 +590,8 @@ static int uhci_start(struct usb_hcd *hcd)
 	init_waitqueue_head(&uhci->waitqh);
 
 #ifdef UHCI_DEBUG_OPS
-	uhci->dentry = debugfs_create_file(hcd->self.bus_name,
-					   S_IFREG|S_IRUGO|S_IWUSR,
-					   uhci_debugfs_root, uhci,
-					   &uhci_debug_operations);
+	debugfs_create_file(hcd->self.bus_name, S_IFREG|S_IRUGO|S_IWUSR,
+			    uhci_debugfs_root, uhci, &uhci_debug_operations);
 #endif
 
 	uhci->frame = dma_alloc_coherent(uhci_dev(uhci),
@@ -702,7 +700,7 @@ static int uhci_start(struct usb_hcd *hcd)
 			uhci->frame, uhci->frame_dma_handle);
 
 err_alloc_frame:
-	debugfs_remove(uhci->dentry);
+	debugfs_remove(debugfs_lookup(hcd->self.bus_name, uhci_debugfs_root));
 
 	return retval;
 }
drivers/usb/host/uhci-hcd.h +0 -4
index 7f9f33c8c232..8ae5ccd26753 100644
@@ -381,10 +381,6 @@ enum uhci_rh_state {
  * The full UHCI controller information:
  */
 struct uhci_hcd {
-
-	/* debugfs */
-	struct dentry *dentry;
-
 	/* Grabbed from PCI */
 	unsigned long io_addr;
 
Signature · 1 line
2.30.1

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/6 USB: host: isp116x: remove dentry pointer for debugfs

There is no need to keep the dentry pointer around for the created debugfs file, as it is only needed when removing it from the system. When it is to be removed, ask debugfs itself for the pointer, to save on storage and make things a bit simpler.

---
 drivers/usb/host/isp116x-hcd.c | 7 +++----
 drivers/usb/host/isp116x.h     | 1 -
 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/usb/host/isp116x-hcd.c +3 -4
index 8544a2a2c1e6..8835f6bd528e 100644
@@ -1200,14 +1200,13 @@ DEFINE_SHOW_ATTRIBUTE(isp116x_debug);
 
 static void create_debug_file(struct isp116x *isp116x)
 {
-	isp116x->dentry = debugfs_create_file(hcd_name,
-					      S_IRUGO, NULL, isp116x,
-					      &isp116x_debug_fops);
+	debugfs_create_file(hcd_name, S_IRUGO, usb_debug_root, isp116x,
+			    &isp116x_debug_fops);
 }
 
 static void remove_debug_file(struct isp116x *isp116x)
 {
-	debugfs_remove(isp116x->dentry);
+	debugfs_remove(debugfs_lookup(hcd_name, usb_debug_root));
 }
 
 #else
drivers/usb/host/isp116x.h +0 -1
index a5e929c10d53..84904025fe7f 100644
@@ -260,7 +260,6 @@ struct isp116x {
 
 	struct isp116x_platform_data *board;
 
-	struct dentry *dentry;
 	unsigned long stat1, stat2, stat4, stat8, stat16;
 
 	/* HC registers */
Signature · 1 line
2.30.1
author maintainer
#4 lore raw

PATCH 5/6 USB: typec: fusb302: create debugfs subdir for the driver

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

---
 drivers/usb/typec/tcpm/fusb302.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/fusb302.c +3 -2
index ebc46b9f776c..7a2a17866a82 100644
@@ -213,8 +213,9 @@ static void fusb302_debugfs_init(struct fusb302_chip *chip)
 
 	mutex_init(&chip->logbuffer_lock);
 	snprintf(name, NAME_MAX, "fusb302-%s", dev_name(chip->dev));
-	chip->dentry = debugfs_create_file(name, S_IFREG | 0444, usb_debug_root,
-					   chip, &fusb302_debug_fops);
+	chip->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, chip->dentry, chip,
+			    &fusb302_debug_fops);
 }
 
 static void fusb302_debugfs_exit(struct fusb302_chip *chip)
Signature · 1 line
2.30.1
author maintainer
#8 lore raw

PATCH 6/6 USB: typec: tcpm: create debugfs subdir for the driver

In reply to Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

---
 drivers/usb/typec/tcpm/tcpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -2
index 22a85b396f69..d4dd40c95a56 100644
@@ -636,8 +636,9 @@ static void tcpm_debugfs_init(struct tcpm_port *port)
 
 	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);
+	port->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, port->dentry, port,
+			    &tcpm_debug_fops);
 }
 
 static void tcpm_debugfs_exit(struct tcpm_port *port)
Signature · 1 line
2.30.1
Reviewed-by on v1 6/6
#9 lore raw

Re: [PATCH 6/6] USB: typec: tcpm: create debugfs subdir for the driver

Quoted 9 lines · Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

Quoted 21 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -2
index 22a85b396f69..d4dd40c95a56 100644
@@ -636,8 +636,9 @@ static void tcpm_debugfs_init(struct tcpm_port *port)
 
 	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);
+	port->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, port->dentry, port,
+			    &tcpm_debug_fops);
 }
 
 static void tcpm_debugfs_exit(struct tcpm_port *port)
Reviewed-by on v1 5/6
#5 lore raw

Re: [PATCH 5/6] USB: typec: fusb302: create debugfs subdir for the driver

In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

I'd probably have explored the possibility to group files like this under the newly created tcpm debugfs directory, but that is really a nitpick.

Guenter

Quoted 21 lines
---
 drivers/usb/typec/tcpm/fusb302.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/fusb302.c +3 -2
index ebc46b9f776c..7a2a17866a82 100644
@@ -213,8 +213,9 @@ static void fusb302_debugfs_init(struct fusb302_chip *chip)
 
 	mutex_init(&chip->logbuffer_lock);
 	snprintf(name, NAME_MAX, "fusb302-%s", dev_name(chip->dev));
-	chip->dentry = debugfs_create_file(name, S_IFREG | 0444, usb_debug_root,
-					   chip, &fusb302_debug_fops);
+	chip->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, chip->dentry, chip,
+			    &fusb302_debug_fops);
 }
 
 static void fusb302_debugfs_exit(struct fusb302_chip *chip)
maintainer Reviewed-by on v1 5/6
#7 lore raw

Re: [PATCH 5/6] USB: typec: fusb302: create debugfs subdir for the driver

In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

Quoted 22 lines
---
 drivers/usb/typec/tcpm/fusb302.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/fusb302.c +3 -2
index ebc46b9f776c..7a2a17866a82 100644
@@ -213,8 +213,9 @@ static void fusb302_debugfs_init(struct fusb302_chip *chip)
 
 	mutex_init(&chip->logbuffer_lock);
 	snprintf(name, NAME_MAX, "fusb302-%s", dev_name(chip->dev));
-	chip->dentry = debugfs_create_file(name, S_IFREG | 0444, usb_debug_root,
-					   chip, &fusb302_debug_fops);
+	chip->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, chip->dentry, chip,
+			    &fusb302_debug_fops);
 }
 
 static void fusb302_debugfs_exit(struct fusb302_chip *chip)
Signature · 1 line
2.30.1
Signature · 1 line
heikki
maintainer Reviewed-by on v1 6/6
#10 lore raw

Re: [PATCH 6/6] USB: typec: tcpm: create debugfs subdir for the driver

In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

Quoted 22 lines
---
 drivers/usb/typec/tcpm/tcpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +3 -2
index 22a85b396f69..d4dd40c95a56 100644
@@ -636,8 +636,9 @@ static void tcpm_debugfs_init(struct tcpm_port *port)
 
 	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);
+	port->dentry = debugfs_create_dir(name, usb_debug_root);
+	debugfs_create_file("log", S_IFREG | 0444, port->dentry, port,
+			    &tcpm_debug_fops);
 }
 
 static void tcpm_debugfs_exit(struct tcpm_port *port)
Signature · 1 line
2.30.1
Signature · 1 line
heikki
author maintainer
#6 lore raw

Re: [PATCH 5/6] USB: typec: fusb302: create debugfs subdir for the driver

In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman

The single debugfs file for this driver really is a log file, so make a subdir and call it "log" to make it obvious this is what it is for. This makes cleanup simpler as we just remove the whole directory, no need to handle individual files anymore.

Quoted 5 lines

I'd probably have explored the possibility to group files like this under the newly created tcpm debugfs directory, but that is really a nitpick.

Good idea, I'll look into doing that next...

thanks,

greg k-h