powerpc/kernel: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Feb 2020 10:58:56 +0000 (11:58 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 4 Mar 2020 11:44:25 +0000 (22:44 +1100)
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.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200209105901.1620958-1-gregkh@linuxfoundation.org
arch/powerpc/kernel/fadump.c
arch/powerpc/kernel/setup-common.c
arch/powerpc/kernel/traps.c

index 265b4aa..59e60a9 100644 (file)
@@ -1455,7 +1455,6 @@ DEFINE_SHOW_ATTRIBUTE(fadump_region);
 
 static void fadump_init_files(void)
 {
-       struct dentry *debugfs_file;
        int rc = 0;
 
        fadump_kobj = kobject_create_and_add("fadump", kernel_kobj);
@@ -1463,12 +1462,9 @@ static void fadump_init_files(void)
                pr_err("failed to create fadump kobject\n");
                return;
        }
-       debugfs_file = debugfs_create_file("fadump_region", 0444,
-                                       powerpc_debugfs_root, NULL,
-                                       &fadump_region_fops);
-       if (!debugfs_file)
-               printk(KERN_ERR "fadump: unable to create debugfs file"
-                               " fadump_region\n");
+
+       debugfs_create_file("fadump_region", 0444, powerpc_debugfs_root, NULL,
+                           &fadump_region_fops);
 
        if (fw_dump.dump_active) {
                rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
index 7f8c890..f9c0d88 100644 (file)
@@ -787,8 +787,7 @@ EXPORT_SYMBOL(powerpc_debugfs_root);
 static int powerpc_debugfs_init(void)
 {
        powerpc_debugfs_root = debugfs_create_dir("powerpc", NULL);
-
-       return powerpc_debugfs_root == NULL;
+       return 0;
 }
 arch_initcall(powerpc_debugfs_init);
 #endif
index 82a3438..3fca222 100644 (file)
@@ -2278,35 +2278,20 @@ void ppc_warn_emulated_print(const char *type)
 
 static int __init ppc_warn_emulated_init(void)
 {
-       struct dentry *dir, *d;
+       struct dentry *dir;
        unsigned int i;
        struct ppc_emulated_entry *entries = (void *)&ppc_emulated;
 
-       if (!powerpc_debugfs_root)
-               return -ENODEV;
-
        dir = debugfs_create_dir("emulated_instructions",
                                 powerpc_debugfs_root);
-       if (!dir)
-               return -ENOMEM;
 
-       d = debugfs_create_u32("do_warn", 0644, dir,
-                              &ppc_warn_emulated);
-       if (!d)
-               goto fail;
+       debugfs_create_u32("do_warn", 0644, dir, &ppc_warn_emulated);
 
-       for (i = 0; i < sizeof(ppc_emulated)/sizeof(*entries); i++) {
-               d = debugfs_create_u32(entries[i].name, 0644, dir,
-                                      (u32 *)&entries[i].val.counter);
-               if (!d)
-                       goto fail;
-       }
+       for (i = 0; i < sizeof(ppc_emulated)/sizeof(*entries); i++)
+               debugfs_create_u32(entries[i].name, 0644, dir,
+                                  (u32 *)&entries[i].val.counter);
 
        return 0;
-
-fail:
-       debugfs_remove_recursive(dir);
-       return -ENOMEM;
 }
 
 device_initcall(ppc_warn_emulated_init);