Skip to contentSkip to conversation

driver core: component: remove dentry pointer in "struct master"

PATCH In review Greg Kroah-Hartman 2 participants 5 messages Feb 16, 2021

Subsystems (2)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/2 driver core: component: remove dentry pointer in "struct master"

There is no need to keep around a pointer to a dentry when all it is used for is to remove the debugfs file when tearing things down. As the name is simple, have debugfs look up the dentry when removing things, keeping the logic much simpler.

---
 drivers/base/component.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/base/component.c +3 -6
index dcfbe7251dc4..272ba42392f0 100644
@@ -65,7 +65,6 @@ struct master {
 	const struct component_master_ops *ops;
 	struct device *dev;
 	struct component_match *match;
-	struct dentry *dentry;
 };
 
 struct component {
@@ -125,15 +124,13 @@ core_initcall(component_debug_init);
 
 static void component_master_debugfs_add(struct master *m)
 {
-	m->dentry = debugfs_create_file(dev_name(m->dev), 0444,
-					component_debugfs_dir,
-					m, &component_devices_fops);
+	debugfs_create_file(dev_name(m->dev), 0444, component_debugfs_dir, m,
+			    &component_devices_fops);
 }
 
 static void component_master_debugfs_del(struct master *m)
 {
-	debugfs_remove(m->dentry);
-	m->dentry = NULL;
+	debugfs_remove(debugfs_lookup(dev_name(m->dev), component_debugfs_dir));
 }
 
 #else
Signature · 1 line
2.30.1
author maintainer
#1 lore raw

PATCH 2/2 driver core: dd: remove deferred_devices variable

No need to save the debugfs dentry for the "devices_deferred" debugfs file (gotta love the juxtaposition), if we need to remove it we can look it up from debugfs itself.

---
 drivers/base/dd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/base/dd.c +3 -4
index 9179825ff646..66c31cda5462 100644
@@ -55,7 +55,6 @@ static DEFINE_MUTEX(deferred_probe_mutex);
 static LIST_HEAD(deferred_probe_pending_list);
 static LIST_HEAD(deferred_probe_active_list);
 static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
-static struct dentry *deferred_devices;
 static bool initcalls_done;
 
 /* Save the async probe drivers' name from kernel cmdline */
@@ -310,8 +309,8 @@ static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_
  */
 static int deferred_probe_initcall(void)
 {
-	deferred_devices = debugfs_create_file("devices_deferred", 0444, NULL,
-					       NULL, &deferred_devs_fops);
+	debugfs_create_file("devices_deferred", 0444, NULL, NULL,
+			    &deferred_devs_fops);
 
 	driver_deferred_probe_enable = true;
 	driver_deferred_probe_trigger();
@@ -336,7 +335,7 @@ late_initcall(deferred_probe_initcall);
 
 static void __exit deferred_probe_exit(void)
 {
-	debugfs_remove_recursive(deferred_devices);
+	debugfs_remove_recursive(debugfs_lookup("devices_deferred", NULL));
 }
 __exitcall(deferred_probe_exit);
 
Signature · 1 line
2.30.1
maintainer Reviewed-by on v1 1/2
#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

There is no need to keep around a pointer to a dentry when all it is used for is to remove the debugfs file when tearing things down. As the name is simple, have debugfs look up the dentry when removing things, keeping the logic much simpler.

Quoted 38 lines
---
 drivers/base/component.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/base/component.c +3 -7
index dcfbe7251dc4..272ba42392f0 100644
@@ -65,7 +65,6 @@ struct master {
        const struct component_master_ops *ops;
        struct device *dev;
        struct component_match *match;
-       struct dentry *dentry;
 };
 
 struct component {
@@ -125,15 +124,13 @@ core_initcall(component_debug_init);
 
 static void component_master_debugfs_add(struct master *m)
 {
-       m->dentry = debugfs_create_file(dev_name(m->dev), 0444,
-                                       component_debugfs_dir,
-                                       m, &component_devices_fops);
+       debugfs_create_file(dev_name(m->dev), 0444, component_debugfs_dir, m,
+                           &component_devices_fops);
 }
 
 static void component_master_debugfs_del(struct master *m)
 {
-       debugfs_remove(m->dentry);
-       m->dentry = NULL;
+       debugfs_remove(debugfs_lookup(dev_name(m->dev), component_debugfs_dir));
 }
 
 #else
--

2.30.1

maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] driver core: dd: remove deferred_devices variable

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

No need to save the debugfs dentry for the "devices_deferred" debugfs file (gotta love the juxtaposition), if we need to remove it we can look it up from debugfs itself.

Quoted 39 lines
---
 drivers/base/dd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/base/dd.c +3 -5
index 9179825ff646..66c31cda5462 100644
@@ -55,7 +55,6 @@ static DEFINE_MUTEX(deferred_probe_mutex);
 static LIST_HEAD(deferred_probe_pending_list);
 static LIST_HEAD(deferred_probe_active_list);
 static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
-static struct dentry *deferred_devices;
 static bool initcalls_done;
 
 /* Save the async probe drivers' name from kernel cmdline */
@@ -310,8 +309,8 @@ static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_
  */
 static int deferred_probe_initcall(void)
 {
-       deferred_devices = debugfs_create_file("devices_deferred", 0444, NULL,
-                                              NULL, &deferred_devs_fops);
+       debugfs_create_file("devices_deferred", 0444, NULL, NULL,
+                           &deferred_devs_fops);
 
        driver_deferred_probe_enable = true;
        driver_deferred_probe_trigger();
@@ -336,7 +335,7 @@ late_initcall(deferred_probe_initcall);
 
 static void __exit deferred_probe_exit(void)
 {
-       debugfs_remove_recursive(deferred_devices);
+       debugfs_remove_recursive(debugfs_lookup("devices_deferred", NULL));
 }
 __exitcall(deferred_probe_exit);
 
--

2.30.1

author maintainer
#3 lore raw

Re: [PATCH 2/2] driver core: dd: remove deferred_devices variable

Quoted 7 lines · Rafael J. Wysocki
Quoted 5 lines · Greg Kroah-Hartman

No need to save the debugfs dentry for the "devices_deferred" debugfs file (gotta love the juxtaposition), if we need to remove it we can look it up from debugfs itself.

Quoted 5 lines
Quoted 3 lines

Thanks for the quick review, I'll queue these up after 5.12-rc1 is out.

greg k-h