Skip to content

Commit d814042

Browse files
gregkhpaulburton
authored andcommitted
mips: kernel: 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. Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Burton <paul.burton@mips.com> Cc: James Hogan <jhogan@kernel.org> Cc: Yangtao Li <tiny.windzz@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> Cc: Mathieu Malaterre <malat@debian.org> Cc: Huacai Chen <chenhc@lemote.com> Cc: Marcin Nowakowski <marcin.nowakowski@mips.com> Cc: Yasha Cherikovsky <yasha.che3@gmail.com> Cc: linux-mips@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Paul Burton <paul.burton@mips.com>
1 parent ef9d5a6 commit d814042

File tree

5 files changed

+16
-64
lines changed

5 files changed

+16
-64
lines changed

arch/mips/kernel/mips-r2-to-r6-emul.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,23 +2351,10 @@ DEFINE_SHOW_ATTRIBUTE(mipsr2_clear);
23512351

23522352
static int __init mipsr2_init_debugfs(void)
23532353
{
2354-
struct dentry *mipsr2_emul;
2355-
2356-
if (!mips_debugfs_dir)
2357-
return -ENODEV;
2358-
2359-
mipsr2_emul = debugfs_create_file("r2_emul_stats", S_IRUGO,
2360-
mips_debugfs_dir, NULL,
2361-
&mipsr2_emul_fops);
2362-
if (!mipsr2_emul)
2363-
return -ENOMEM;
2364-
2365-
mipsr2_emul = debugfs_create_file("r2_emul_stats_clear", S_IRUGO,
2366-
mips_debugfs_dir, NULL,
2367-
&mipsr2_clear_fops);
2368-
if (!mipsr2_emul)
2369-
return -ENOMEM;
2370-
2354+
debugfs_create_file("r2_emul_stats", S_IRUGO, mips_debugfs_dir, NULL,
2355+
&mipsr2_emul_fops);
2356+
debugfs_create_file("r2_emul_stats_clear", S_IRUGO, mips_debugfs_dir,
2357+
NULL, &mipsr2_clear_fops);
23712358
return 0;
23722359
}
23732360

arch/mips/kernel/segment.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,9 @@ static const struct file_operations segments_fops = {
9595

9696
static int __init segments_info(void)
9797
{
98-
struct dentry *segments;
99-
100-
if (cpu_has_segments) {
101-
if (!mips_debugfs_dir)
102-
return -ENODEV;
103-
104-
segments = debugfs_create_file("segments", S_IRUGO,
105-
mips_debugfs_dir, NULL,
106-
&segments_fops);
107-
if (!segments)
108-
return -ENOMEM;
109-
}
98+
if (cpu_has_segments)
99+
debugfs_create_file("segments", S_IRUGO, mips_debugfs_dir, NULL,
100+
&segments_fops);
110101
return 0;
111102
}
112103

arch/mips/kernel/setup.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,12 +1010,7 @@ unsigned long fw_passed_dtb;
10101010
struct dentry *mips_debugfs_dir;
10111011
static int __init debugfs_mips(void)
10121012
{
1013-
struct dentry *d;
1014-
1015-
d = debugfs_create_dir("mips", NULL);
1016-
if (!d)
1017-
return -ENOMEM;
1018-
mips_debugfs_dir = d;
1013+
mips_debugfs_dir = debugfs_create_dir("mips", NULL);
10191014
return 0;
10201015
}
10211016
arch_initcall(debugfs_mips);

arch/mips/kernel/spinlock_test.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,10 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_multi, multi_get, NULL, "%llu\n");
118118

119119
static int __init spinlock_test(void)
120120
{
121-
struct dentry *d;
122-
123-
if (!mips_debugfs_dir)
124-
return -ENODEV;
125-
126-
d = debugfs_create_file("spin_single", S_IRUGO,
127-
mips_debugfs_dir, NULL,
128-
&fops_ss);
129-
if (!d)
130-
return -ENOMEM;
131-
132-
d = debugfs_create_file("spin_multi", S_IRUGO,
133-
mips_debugfs_dir, NULL,
134-
&fops_multi);
135-
if (!d)
136-
return -ENOMEM;
137-
121+
debugfs_create_file("spin_single", S_IRUGO, mips_debugfs_dir, NULL,
122+
&fops_ss);
123+
debugfs_create_file("spin_multi", S_IRUGO, mips_debugfs_dir, NULL,
124+
&fops_multi);
138125
return 0;
139126
}
140127
device_initcall(spinlock_test);

arch/mips/kernel/unaligned.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,18 +2374,10 @@ asmlinkage void do_ade(struct pt_regs *regs)
23742374
#ifdef CONFIG_DEBUG_FS
23752375
static int __init debugfs_unaligned(void)
23762376
{
2377-
struct dentry *d;
2378-
2379-
if (!mips_debugfs_dir)
2380-
return -ENODEV;
2381-
d = debugfs_create_u32("unaligned_instructions", S_IRUGO,
2382-
mips_debugfs_dir, &unaligned_instructions);
2383-
if (!d)
2384-
return -ENOMEM;
2385-
d = debugfs_create_u32("unaligned_action", S_IRUGO | S_IWUSR,
2386-
mips_debugfs_dir, &unaligned_action);
2387-
if (!d)
2388-
return -ENOMEM;
2377+
debugfs_create_u32("unaligned_instructions", S_IRUGO, mips_debugfs_dir,
2378+
&unaligned_instructions);
2379+
debugfs_create_u32("unaligned_action", S_IRUGO | S_IWUSR,
2380+
mips_debugfs_dir, &unaligned_action);
23892381
return 0;
23902382
}
23912383
arch_initcall(debugfs_unaligned);

0 commit comments

Comments
 (0)