lvts_thermal.c: Drop error checking for debugfs_create_dir
PATCH 1/1 lvts_thermal.c: Drop error checking for debugfs_create_dir
This patch removes the error checking for debugfs_create_dir in lvts_thermal.c. This is because the debugfs_create_dir() does not return NULL but an ERR_PTR after an error. The DebugFS kernel API is developed in a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes.The debugfs Api handles it gracefully. The check is unnecessary.
Link to the comment above debugfs_create_dir:
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451
--- drivers/thermal/mediatek/lvts_thermal.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/thermal/mediatek/lvts_thermal.c +4 -9
@@ -179,7 +179,7 @@ static const struct debugfs_reg32 lvts_regs[] = { LVTS_DEBUG_FS_REGS(LVTS_CLKEN), }; -static int lvts_debugfs_init (struct device *dev,struct lvts_domain *lvts_td) +static void lvts_debugfs_init (struct device *dev,struct lvts_domain *lvts_td) {struct debugfs_regset32 *regset;struct lvts_ctrl *lvts_ctrl;
@@ -188,8 +188,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)int i; lvts_td->dom_dentry =debugfs_create_dir (dev_name (dev),NULL ); -if (!lvts_td->dom_dentry) -return 0 ;for (i =0 ; i < lvts_td->num_lvts_ctrl; i++) {
@@ -197,8 +195,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)sprintf (name,"controller%d" , i); dentry =debugfs_create_dir (name, lvts_td->dom_dentry); -if (!dentry) -continue ; regset =devm_kzalloc (dev,sizeof (*regset),GFP_KERNEL );if (!regset)
@@ -211,7 +207,6 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)debugfs_create_regset32 ("registers" ,0400 , dentry, regset); } -return 0 ; }static void lvts_debugfs_exit (struct lvts_domain *lvts_td)
@@ -221,10 +216,9 @@ static void lvts_debugfs_exit(struct lvts_domain *lvts_td)#else -static inline int lvts_debugfs_init (struct device *dev, +static inline void lvts_debugfs_init (struct device *dev,struct lvts_domain *lvts_td) { -return 0 ; }static void lvts_debugfs_exit (struct lvts_domain *lvts_td) { }
@@ -1099,7 +1093,8 @@ static int lvts_domain_init(struct device *dev, struct lvts_domain *lvts_td, } } -return lvts_debugfs_init (dev, lvts_td); +lvts_debugfs_init (dev, lvts_td); +return 0 ; }static int lvts_probe (struct platform_device *pdev)
Signature · 1 line
2.34.1
Quoted 8 lines · Osama Muhammad
This patch removes the error checking for
debugfs_create_dirinlvts_thermal.c. This is because thedebugfs_create_dir()does not return NULL but anERR_PTRafter an error. The DebugFS kernel API is developed in a way that the caller can safely ignore the errors that occur during the creation of DebugFS nodes.The debugfs Api handles it gracefully. The check is unnecessary.
Quoted 4 lines
Link to the comment above
debugfs_create_dir:
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451Signed-off-by Osama Muhammad <[email protected]>
Is this patch tested ?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog