regmap: no need to check return value of debugfs_create functions
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 1/1 regmap: no need to check return value of debugfs_create functions
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
--- drivers/base/regmap/regmap-debugfs.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/base/regmap/regmap-debugfs.c +0 -12
@@ -572,14 +572,6 @@ void regmap_debugfs_init(struct regmap *map, const char *name) } map->debugfs =debugfs_create_dir (name, regmap_debugfs_root); -if (!map->debugfs) { -dev_warn (map->dev, -"Failed to create %s debugfs directory\n" , name); - -kfree (map->debugfs_name); - map->debugfs_name =NULL ; -return ; - }debugfs_create_file ("name" ,0400 , map->debugfs, map, ®map_name_fops);
@@ -656,10 +648,6 @@ void regmap_debugfs_initcall(void)struct regmap_debugfs_node *node, *tmp; regmap_debugfs_root =debugfs_create_dir ("regmap" ,NULL ); -if (!regmap_debugfs_root) { -pr_warn ("regmap: Failed to create debugfs root\n" ); -return ; - }mutex_lock (®map_debugfs_early_lock);list_for_each_entry_safe (node, tmp, ®map_debugfs_early_list, link) {
Signature · 1 line
2.20.1
Mark Brown
maintainerQuoted 3 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Given that all the rest of the function is doing is further debugfs operations and when it fails people trying to use the debugfs do welcome some diagnostics I'm not sure that's particularly helpful.
Greg Kroah-Hartman
maintainerQuoted 8 lines · Mark Brown
Quoted 3 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Given that all the rest of the function is doing is further debugfs operations and when it fails people trying to use the debugfs do welcome some diagnostics I'm not sure that's particularly helpful.
The only way it will fail is if we are out of memory. And you are in a bigger mess then, no one cares about debugfs calls, just make them and move on, you should never care about the result of such a call.
thanks,
greg k-h
Mark Brown
maintainerQuoted 9 lines · Greg Kroah-Hartman
Quoted 3 lines · Mark Brown
Given that all the rest of the function is doing is further debugfs operations and when it fails people trying to use the debugfs do welcome some diagnostics I'm not sure that's particularly helpful.
The only way it will fail is if we are out of memory. And you are in a bigger mess then, no one cares about debugfs calls, just make them and move on, you should never care about the result of such a call.
No, it also fails if there's already something with the same name in debugfs which can happen as as a result of configuration. This gets confusing for users, they see the debugfs files they're expecting but the contents don't match up at all.
Greg Kroah-Hartman
maintainerQuoted 7 lines · Mark Brown
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Mark Brown
Given that all the rest of the function is doing is further debugfs operations and when it fails people trying to use the debugfs do welcome some diagnostics I'm not sure that's particularly helpful.
Quoted 8 lines
Quoted 3 lines
The only way it will fail is if we are out of memory. And you are in a bigger mess then, no one cares about debugfs calls, just make them and move on, you should never care about the result of such a call.
No, it also fails if there's already something with the same name in debugfs which can happen as as a result of configuration. This gets confusing for users, they see the debugfs files they're expecting but the contents don't match up at all.
How can you allow a duplicate name for the other regmap stuff? Will that not also cause a collision somewhere else?
Anyway, if this is that big of a problem, ok, but then your code will run differently if debugfs is enabled or not, which isn't ok. Don't rely on debugfs to do your name filtering for you :)
thanks,
greg k-h
Mark Brown
maintainerQuoted 9 lines · Greg Kroah-Hartman
Quoted 4 lines · Mark Brown
No, it also fails if there's already something with the same name in debugfs which can happen as as a result of configuration. This gets confusing for users, they see the debugfs files they're expecting but the contents don't match up at all.
How can you allow a duplicate name for the other regmap stuff? Will that not also cause a collision somewhere else?
No, the only place we actually use the names for anything is when creating the debugfs. Otherwise the driver using the regmap deals with a pointer to the regmap which doesn't have any collision risk.
Quoted 3 lines
Anyway, if this is that big of a problem, ok, but then your code will run differently if debugfs is enabled or not, which isn't ok. Don't rely on debugfs to do your name filtering for you :)
I'd rather hope that the debugfs creation code runs differently depending on if debugfs is enabled, perhaps that's just a strange foible of mine. :)