driver core: component: remove dentry pointer in "struct master"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Feb 2021 14:23:59 +0000 (15:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Mar 2021 09:49:02 +0000 (10:49 +0100)
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.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20210216142400.3759099-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/component.c

index dcfbe72..272ba42 100644 (file)
@@ -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