driver core: component: remove dentry pointer in "struct master"
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 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
@@ -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
Greg Kroah-Hartman
maintainerPATCH 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
@@ -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
Re: [PATCH 2/2] driver core: dd: remove deferred_devices variable
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.Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 39 lines
--- drivers/base/dd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/base/dd.c +3
-5@@ -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
Greg Kroah-Hartman
maintainerRe: [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
Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Reviewed-by Rafael J. Wysocki <[email protected]>
Thanks for the quick review, I'll queue these up after 5.12-rc1 is out.
greg k-h
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.
Cc "Rafael J. Wysocki" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 38 lines
--- drivers/base/component.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/base/component.c +3
-7@@ -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