ARM: cleanup debugfs usage
Subsystems (7)
PATCH 3/4 arm: omap1: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- arch/arm/mach-omap1/clock.c | 63 +++++++------------------------------ arch/arm/mach-omap1/pm.c | 7 ++--- 2 files changed, 14 insertions(+), 56 deletions(-)
arch/arm/mach-omap1/clock.c +12 -51
@@ -990,84 +990,45 @@ static int debug_clock_show(struct seq_file *s, void *unused)DEFINE_SHOW_ATTRIBUTE (debug_clock); -static int clk_debugfs_register_one (struct clk *c) +static void clk_debugfs_register_one (struct clk *c) { -int err;struct dentry *d;struct clk *pa = c->parent; d =debugfs_create_dir (c->name, pa ? pa->dent : clk_debugfs_root); -if (!d) -return -ENOMEM ; c->dent = d; - d =debugfs_create_u8 ("usecount" ,S_IRUGO , c->dent, &c->usecount); -if (!d) { - err = -ENOMEM ; - goto err_out; - } - d =debugfs_create_ulong ("rate" ,S_IRUGO , c->dent, &c->rate); -if (!d) { - err = -ENOMEM ; - goto err_out; - } - d =debugfs_create_x8 ("flags" ,S_IRUGO , c->dent, &c->flags); -if (!d) { - err = -ENOMEM ; - goto err_out; - } -return 0 ; - -err_out: -debugfs_remove_recursive (c->dent); -return err; +debugfs_create_u8 ("usecount" ,S_IRUGO , c->dent, &c->usecount); +debugfs_create_ulong ("rate" ,S_IRUGO , c->dent, &c->rate); +debugfs_create_x8 ("flags" ,S_IRUGO , c->dent, &c->flags); } -static int clk_debugfs_register (struct clk *c) +static void clk_debugfs_register (struct clk *c) {int err;struct clk *pa = c->parent; -if (pa && !pa->dent) { - err =clk_debugfs_register (pa); -if (err) -return err; - } +if (pa && !pa->dent) +clk_debugfs_register (pa); -if (!c->dent) { - err =clk_debugfs_register_one (c); -if (err) -return err; - } -return 0 ; +if (!c->dent) +clk_debugfs_register_one (c); }static int __init clk_debugfs_init (void ) {struct clk *c;struct dentry *d; -int err; d =debugfs_create_dir ("clock" ,NULL ); -if (!d) -return -ENOMEM ; clk_debugfs_root = d; -list_for_each_entry (c, &clocks, node) { - err =clk_debugfs_register (c); -if (err) - goto err_out; - } +list_for_each_entry (c, &clocks, node) +clk_debugfs_register (c); - d =debugfs_create_file ("summary" ,S_IRUGO , - d,NULL , &debug_clock_fops); -if (!d) -return -ENOMEM ; +debugfs_create_file ("summary" ,S_IRUGO , d,NULL , &debug_clock_fops);return 0 ; -err_out: -debugfs_remove_recursive (clk_debugfs_root); -return err; }late_initcall (clk_debugfs_init);
arch/arm/mach-omap1/pm.c +2 -5
@@ -539,11 +539,8 @@ static void omap_pm_init_debugfs(void)struct dentry *d; d =debugfs_create_dir ("pm_debug" ,NULL ); -if (!d) -return ; - - (void )debugfs_create_file ("omap_pm" ,S_IWUSR |S_IRUGO , - d, NULL, &omap_pm_debug_fops); +debugfs_create_file ("omap_pm" ,S_IWUSR |S_IRUGO , d,NULL , + &omap_pm_debug_fops); }#endif /* CONFIG_DEBUG_FS */
Signature · 1 line
2.20.1
PATCH 4/4 arm: omap2: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- arch/arm/mach-omap2/pm-debug.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
arch/arm/mach-omap2/pm-debug.c +6 -9
@@ -193,9 +193,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)return 0 ; d =debugfs_create_dir (pwrdm->name, (struct dentry *)dir); -if (d) - (void )debugfs_create_file ("suspend" ,S_IRUGO |S_IWUSR , d, - (void *)pwrdm, &pwrdm_suspend_fops); +debugfs_create_file ("suspend" ,S_IRUGO |S_IWUSR , d, pwrdm, + &pwrdm_suspend_fops);return 0 ; }
@@ -233,16 +232,14 @@ static int __init pm_dbg_init(void)return 0 ; d =debugfs_create_dir ("pm_debug" ,NULL ); -if (!d) -return -EINVAL ; - (void )debugfs_create_file ("count" ,0444 , d,NULL , &pm_dbg_counters_fops); - (void )debugfs_create_file ("time" ,0444 , d,NULL , &pm_dbg_timers_fops); +debugfs_create_file ("count" ,0444 , d,NULL , &pm_dbg_counters_fops); +debugfs_create_file ("time" ,0444 , d,NULL , &pm_dbg_timers_fops);pwrdm_for_each (pwrdms_setup, (void *)d); - (void )debugfs_create_file ("enable_off_mode" ,S_IRUGO |S_IWUSR , d, - &enable_off_mode, &pm_dbg_option_fops); +debugfs_create_file ("enable_off_mode" ,S_IRUGO |S_IWUSR , d, + &enable_off_mode, &pm_dbg_option_fops); pm_dbg_init_done =1 ;return 0 ;
Signature · 1 line
2.20.1
cover ARM: cleanup debugfs usage
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of x86-specific code to not care about the results of debugfs
Greg Kroah-Hartman (4):
arm64: dump: no need to check return value of debugfs_create functions
arm: dump: no need to check return value of debugfs_create functions
arm: omap1: no need to check return value of debugfs_create functions
arm: omap2: no need to check return value of debugfs_create functions
arch/arm/include/asm/ptdump.h | 9 ++--- arch/arm/mach-omap1/clock.c | 63 +++++++-------------------------- arch/arm/mach-omap1/pm.c | 7 ++-- arch/arm/mach-omap2/pm-debug.c | 15 ++++---- arch/arm/mm/dump.c | 4 +-- arch/arm/mm/ptdump_debugfs.c | 8 ++--- arch/arm64/include/asm/ptdump.h | 9 ++--- arch/arm64/mm/dump.c | 4 +-- arch/arm64/mm/ptdump_debugfs.c | 7 ++-- 9 files changed, 34 insertions(+), 92 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/4 arm64: dump: 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.
--- arch/arm64/include/asm/ptdump.h | 9 +++------ arch/arm64/mm/dump.c | 4 ++-- arch/arm64/mm/ptdump_debugfs.c | 7 ++----- 3 files changed, 7 insertions(+), 13 deletions(-)
arch/arm64/include/asm/ptdump.h +3 -6
@@ -34,13 +34,10 @@ struct ptdump_info {void ptdump_walk_pgd (struct seq_file *s,struct ptdump_info *info);#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS -int ptdump_debugfs_register (struct ptdump_info *info,const char *name); +void ptdump_debugfs_register (struct ptdump_info *info,const char *name);#else -static inline int ptdump_debugfs_register (struct ptdump_info *info, -const char *name) -{ -return 0 ; -} +static inline void ptdump_debugfs_register (struct ptdump_info *info, +const char *name) { }#endif void ptdump_check_wx (void );#endif /* CONFIG_ARM64_PTDUMP_CORE */
arch/arm64/mm/dump.c +2 -2
@@ -407,7 +407,7 @@ void ptdump_check_wx(void)static int ptdump_init (void ) {ptdump_initialize (); -return ptdump_debugfs_register (&kernel_ptdump_info, -"kernel_page_tables" ); +ptdump_debugfs_register (&kernel_ptdump_info,"kernel_page_tables" ); +return 0 ; }device_initcall (ptdump_init);
arch/arm64/mm/ptdump_debugfs.c +2 -5
@@ -12,10 +12,7 @@ static int ptdump_show(struct seq_file *m, void *v) }DEFINE_SHOW_ATTRIBUTE (ptdump); -int ptdump_debugfs_register (struct ptdump_info *info,const char *name) +void ptdump_debugfs_register (struct ptdump_info *info,const char *name) { -struct dentry *pe; - pe =debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); -return pe ?0 : -ENOMEM ; - +debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); }
Signature · 1 line
2.20.1
PATCH 2/4 arm: dump: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- arch/arm/include/asm/ptdump.h | 9 +++------ arch/arm/mm/dump.c | 4 ++-- arch/arm/mm/ptdump_debugfs.c | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-)
arch/arm/include/asm/ptdump.h +3 -6
@@ -21,13 +21,10 @@ struct ptdump_info {void ptdump_walk_pgd (struct seq_file *s,struct ptdump_info *info);#ifdef CONFIG_ARM_PTDUMP_DEBUGFS -int ptdump_debugfs_register (struct ptdump_info *info,const char *name); +void ptdump_debugfs_register (struct ptdump_info *info,const char *name);#else -static inline int ptdump_debugfs_register (struct ptdump_info *info, -const char *name) -{ -return 0 ; -} +static inline void ptdump_debugfs_register (struct ptdump_info *info, +const char *name) { }#endif /* CONFIG_ARM_PTDUMP_DEBUGFS */ void ptdump_check_wx (void );
arch/arm/mm/dump.c +2 -2
@@ -450,7 +450,7 @@ void ptdump_check_wx(void)static int ptdump_init (void ) {ptdump_initialize (); -return ptdump_debugfs_register (&kernel_ptdump_info, -"kernel_page_tables" ); +ptdump_debugfs_register (&kernel_ptdump_info,"kernel_page_tables" ); +return 0 ; }__initcall (ptdump_init);
arch/arm/mm/ptdump_debugfs.c +2 -6
@@ -24,11 +24,7 @@ static const struct file_operations ptdump_fops = { .release = single_release, }; -int ptdump_debugfs_register (struct ptdump_info *info,const char *name) +void ptdump_debugfs_register (struct ptdump_info *info,const char *name) { -struct dentry *pe; - - pe =debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); -return pe ?0 : -ENOMEM ; - +debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); }
Signature · 1 line
2.20.1
Re: [PATCH 2/4] arm: dump: no need to check return value of debugfs_create functions
Quoted 11 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.
Cc Russell King <[email protected]>Cc Jinbum Park <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Do you mean that it bubbles up to an initcall, and the return value is meaningless there? This seems fine to me...
-Kees
Quoted 62 lines
--- arch/arm/include/asm/ptdump.h | 9 +++------ arch/arm/mm/dump.c | 4 ++-- arch/arm/mm/ptdump_debugfs.c | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-)arch/arm/include/asm/ptdump.h +3
-6@@ -21,13 +21,10 @@ struct ptdump_info {void ptdump_walk_pgd (struct seq_file *s,struct ptdump_info *info);#ifdef CONFIG_ARM_PTDUMP_DEBUGFS -int ptdump_debugfs_register (struct ptdump_info *info,const char *name); +void ptdump_debugfs_register (struct ptdump_info *info,const char *name);#else -static inline int ptdump_debugfs_register (struct ptdump_info *info, -const char *name) -{ -return 0 ; -} +static inline void ptdump_debugfs_register (struct ptdump_info *info, +const char *name) { }#endif /* CONFIG_ARM_PTDUMP_DEBUGFS */ void ptdump_check_wx (void );arch/arm/mm/dump.c +2
-2@@ -450,7 +450,7 @@ void ptdump_check_wx(void)static int ptdump_init (void ) {ptdump_initialize (); -return ptdump_debugfs_register (&kernel_ptdump_info, -"kernel_page_tables" ); +ptdump_debugfs_register (&kernel_ptdump_info,"kernel_page_tables" ); +return 0 ; }__initcall (ptdump_init);arch/arm/mm/ptdump_debugfs.c +2
-7@@ -24,11 +24,7 @@ static const struct file_operations ptdump_fops = { .release = single_release, }; -int ptdump_debugfs_register (struct ptdump_info *info,const char *name) +void ptdump_debugfs_register (struct ptdump_info *info,const char *name) { -struct dentry *pe; - - pe =debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); -return pe ?0 : -ENOMEM ; - +debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); } --2.20.1
Signature · 1 line
Kees Cook
Re: [PATCH 3/4] arm: omap1: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanQuoted 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.
Re: [PATCH 4/4] arm: omap2: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanQuoted 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.
Re: [PATCH 2/4] arm: dump: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanQuoted 8 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.
Cc Russell King <[email protected]>Cc Jinbum Park <[email protected]>Cc Kees Cook <[email protected]>Cc Laura Abbott <[email protected]>
Quoted 62 lines
Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/arm/include/asm/ptdump.h | 9 +++------ arch/arm/mm/dump.c | 4 ++-- arch/arm/mm/ptdump_debugfs.c | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-)arch/arm/include/asm/ptdump.h +3
-6@@ -21,13 +21,10 @@ struct ptdump_info {void ptdump_walk_pgd (struct seq_file *s,struct ptdump_info *info);#ifdef CONFIG_ARM_PTDUMP_DEBUGFS -int ptdump_debugfs_register (struct ptdump_info *info,const char *name); +void ptdump_debugfs_register (struct ptdump_info *info,const char *name);#else -static inline int ptdump_debugfs_register (struct ptdump_info *info, -const char *name) -{ -return 0 ; -} +static inline void ptdump_debugfs_register (struct ptdump_info *info, +const char *name) { }#endif /* CONFIG_ARM_PTDUMP_DEBUGFS */ void ptdump_check_wx (void );arch/arm/mm/dump.c +2
-2@@ -450,7 +450,7 @@ void ptdump_check_wx(void)static int ptdump_init (void ) {ptdump_initialize (); -return ptdump_debugfs_register (&kernel_ptdump_info, -"kernel_page_tables" ); +ptdump_debugfs_register (&kernel_ptdump_info,"kernel_page_tables" ); +return 0 ; }__initcall (ptdump_init);arch/arm/mm/ptdump_debugfs.c +2
-6@@ -24,11 +24,7 @@ static const struct file_operations ptdump_fops = { .release = single_release, }; -int ptdump_debugfs_register (struct ptdump_info *info,const char *name) +void ptdump_debugfs_register (struct ptdump_info *info,const char *name) { -struct dentry *pe; - - pe =debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); -return pe ?0 : -ENOMEM ; - +debugfs_create_file (name,0400 ,NULL , info, &ptdump_fops); }
Re: [PATCH 1/4] arm64: dump: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanQuoted 10 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.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Marc Zyngier <[email protected]>Cc Peng Donglin <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Re: [PATCH 1/4] arm64: dump: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanHi Greg,
Quoted 10 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.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Marc Zyngier <[email protected]>Cc Peng Donglin <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 5 lines
--- arch/arm64/include/asm/ptdump.h | 9 +++------ arch/arm64/mm/dump.c | 4 ++-- arch/arm64/mm/ptdump_debugfs.c | 7 ++----- 3 files changed, 7 insertions(+), 13 deletions(-)
Are you taking this via your tree, or would you like us to queue it in arm64?
Will
Re: [PATCH 1/4] arm64: dump: no need to check return value of debugfs_create functions
Quoted 19 lines · Will Deacon
Hi Greg,
Quoted 10 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.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Marc Zyngier <[email protected]>Cc Peng Donglin <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Quoted 5 lines
--- arch/arm64/include/asm/ptdump.h | 9 +++------ arch/arm64/mm/dump.c | 4 ++-- arch/arm64/mm/ptdump_debugfs.c | 7 ++----- 3 files changed, 7 insertions(+), 13 deletions(-)
Quoted 2 lines
Are you taking this via your tree, or would you like us to queue it in arm64?
What ever is easiest for you is fine with me, I can handle it either way, just let me know.
thanks,
greg k-h
Re: [PATCH 1/4] arm64: dump: no need to check return value of debugfs_create functions
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Will Deacon
Hi Greg,
Quoted 15 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.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Marc Zyngier <[email protected]>Cc Peng Donglin <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/arm64/include/asm/ptdump.h | 9 +++------ arch/arm64/mm/dump.c | 4 ++-- arch/arm64/mm/ptdump_debugfs.c | 7 ++----- 3 files changed, 7 insertions(+), 13 deletions(-)
Quoted 5 lines
Quoted 2 lines
Are you taking this via your tree, or would you like us to queue it in arm64?
What ever is easiest for you is fine with me, I can handle it either way, just let me know.
It's easy enough for us to merge the arm64 bits, so we'll pick that up for 5.1.
Cheers,
Will