Skip to content

Commit 9ec6dbf

Browse files
gregkhrafaeljw
authored andcommitted
ACPI: 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. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 49a5785 commit 9ec6dbf

File tree

4 files changed

+32
-111
lines changed

4 files changed

+32
-111
lines changed

drivers/acpi/acpi_dbg.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,6 @@ int __init acpi_aml_init(void)
752752
{
753753
int ret = 0;
754754

755-
if (!acpi_debugfs_dir) {
756-
ret = -ENOENT;
757-
goto err_exit;
758-
}
759-
760755
/* Initialize AML IO interface */
761756
mutex_init(&acpi_aml_io.lock);
762757
init_waitqueue_head(&acpi_aml_io.wait);
@@ -766,10 +761,6 @@ int __init acpi_aml_init(void)
766761
S_IFREG | S_IRUGO | S_IWUSR,
767762
acpi_debugfs_dir, NULL,
768763
&acpi_aml_operations);
769-
if (acpi_aml_dentry == NULL) {
770-
ret = -ENODEV;
771-
goto err_exit;
772-
}
773764
ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
774765
if (ret)
775766
goto err_fs;
@@ -788,10 +779,8 @@ void __exit acpi_aml_exit(void)
788779
{
789780
if (acpi_aml_initialized) {
790781
acpi_unregister_debugger(&acpi_aml_debugger);
791-
if (acpi_aml_dentry) {
792-
debugfs_remove(acpi_aml_dentry);
793-
acpi_aml_dentry = NULL;
794-
}
782+
debugfs_remove(acpi_aml_dentry);
783+
acpi_aml_dentry = NULL;
795784
acpi_aml_initialized = false;
796785
}
797786
}

drivers/acpi/apei/einj.c

Lines changed: 22 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ static int __init einj_init(void)
679679
{
680680
int rc;
681681
acpi_status status;
682-
struct dentry *fentry;
683682
struct apei_exec_context ctx;
684683

685684
if (acpi_disabled) {
@@ -707,25 +706,13 @@ static int __init einj_init(void)
707706

708707
rc = -ENOMEM;
709708
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
710-
if (!einj_debug_dir) {
711-
pr_err("Error creating debugfs node.\n");
712-
goto err_cleanup;
713-
}
714709

715-
fentry = debugfs_create_file("available_error_type", S_IRUSR,
716-
einj_debug_dir, NULL,
717-
&available_error_type_fops);
718-
if (!fentry)
719-
goto err_cleanup;
720-
721-
fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
722-
einj_debug_dir, NULL, &error_type_fops);
723-
if (!fentry)
724-
goto err_cleanup;
725-
fentry = debugfs_create_file("error_inject", S_IWUSR,
726-
einj_debug_dir, NULL, &error_inject_fops);
727-
if (!fentry)
728-
goto err_cleanup;
710+
debugfs_create_file("available_error_type", S_IRUSR, einj_debug_dir,
711+
NULL, &available_error_type_fops);
712+
debugfs_create_file("error_type", S_IRUSR | S_IWUSR, einj_debug_dir,
713+
NULL, &error_type_fops);
714+
debugfs_create_file("error_inject", S_IWUSR, einj_debug_dir,
715+
NULL, &error_inject_fops);
729716

730717
apei_resources_init(&einj_resources);
731718
einj_exec_ctx_init(&ctx);
@@ -750,66 +737,37 @@ static int __init einj_init(void)
750737
rc = -ENOMEM;
751738
einj_param = einj_get_parameter_address();
752739
if ((param_extension || acpi5) && einj_param) {
753-
fentry = debugfs_create_x32("flags", S_IRUSR | S_IWUSR,
754-
einj_debug_dir, &error_flags);
755-
if (!fentry)
756-
goto err_unmap;
757-
fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR,
758-
einj_debug_dir, &error_param1);
759-
if (!fentry)
760-
goto err_unmap;
761-
fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR,
762-
einj_debug_dir, &error_param2);
763-
if (!fentry)
764-
goto err_unmap;
765-
fentry = debugfs_create_x64("param3", S_IRUSR | S_IWUSR,
766-
einj_debug_dir, &error_param3);
767-
if (!fentry)
768-
goto err_unmap;
769-
fentry = debugfs_create_x64("param4", S_IRUSR | S_IWUSR,
770-
einj_debug_dir, &error_param4);
771-
if (!fentry)
772-
goto err_unmap;
773-
774-
fentry = debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
775-
einj_debug_dir, &notrigger);
776-
if (!fentry)
777-
goto err_unmap;
740+
debugfs_create_x32("flags", S_IRUSR | S_IWUSR, einj_debug_dir,
741+
&error_flags);
742+
debugfs_create_x64("param1", S_IRUSR | S_IWUSR, einj_debug_dir,
743+
&error_param1);
744+
debugfs_create_x64("param2", S_IRUSR | S_IWUSR, einj_debug_dir,
745+
&error_param2);
746+
debugfs_create_x64("param3", S_IRUSR | S_IWUSR, einj_debug_dir,
747+
&error_param3);
748+
debugfs_create_x64("param4", S_IRUSR | S_IWUSR, einj_debug_dir,
749+
&error_param4);
750+
debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
751+
einj_debug_dir, &notrigger);
778752
}
779753

780754
if (vendor_dev[0]) {
781755
vendor_blob.data = vendor_dev;
782756
vendor_blob.size = strlen(vendor_dev);
783-
fentry = debugfs_create_blob("vendor", S_IRUSR,
784-
einj_debug_dir, &vendor_blob);
785-
if (!fentry)
786-
goto err_unmap;
787-
fentry = debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
788-
einj_debug_dir, &vendor_flags);
789-
if (!fentry)
790-
goto err_unmap;
757+
debugfs_create_blob("vendor", S_IRUSR, einj_debug_dir,
758+
&vendor_blob);
759+
debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
760+
einj_debug_dir, &vendor_flags);
791761
}
792762

793763
pr_info("Error INJection is initialized.\n");
794764

795765
return 0;
796766

797-
err_unmap:
798-
if (einj_param) {
799-
acpi_size size = (acpi5) ?
800-
sizeof(struct set_error_type_with_address) :
801-
sizeof(struct einj_parameter);
802-
803-
acpi_os_unmap_iomem(einj_param, size);
804-
pr_err("Error creating param extension debugfs nodes.\n");
805-
}
806-
apei_exec_post_unmap_gars(&ctx);
807767
err_release:
808768
apei_resources_release(&einj_resources);
809769
err_fini:
810770
apei_resources_fini(&einj_resources);
811-
err_cleanup:
812-
pr_err("Error creating primary debugfs nodes.\n");
813771
debugfs_remove_recursive(einj_debug_dir);
814772

815773
return rc;

drivers/acpi/custom_method.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,8 @@ static const struct file_operations cm_fops = {
7979

8080
static int __init acpi_custom_method_init(void)
8181
{
82-
if (acpi_debugfs_dir == NULL)
83-
return -ENOENT;
84-
8582
cm_dentry = debugfs_create_file("custom_method", S_IWUSR,
8683
acpi_debugfs_dir, NULL, &cm_fops);
87-
if (cm_dentry == NULL)
88-
return -ENODEV;
89-
9084
return 0;
9185
}
9286

drivers/acpi/ec_sys.c

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,52 +108,32 @@ static const struct file_operations acpi_ec_io_ops = {
108108
.llseek = default_llseek,
109109
};
110110

111-
static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
111+
static void acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
112112
{
113113
struct dentry *dev_dir;
114114
char name[64];
115115
umode_t mode = 0400;
116116

117-
if (ec_device_count == 0) {
117+
if (ec_device_count == 0)
118118
acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL);
119-
if (!acpi_ec_debugfs_dir)
120-
return -ENOMEM;
121-
}
122119

123120
sprintf(name, "ec%u", ec_device_count);
124121
dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir);
125-
if (!dev_dir) {
126-
if (ec_device_count != 0)
127-
goto error;
128-
return -ENOMEM;
129-
}
130122

131-
if (!debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe))
132-
goto error;
133-
if (!debugfs_create_bool("use_global_lock", 0444, dev_dir,
134-
&first_ec->global_lock))
135-
goto error;
123+
debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe);
124+
debugfs_create_bool("use_global_lock", 0444, dev_dir,
125+
&first_ec->global_lock);
136126

137127
if (write_support)
138128
mode = 0600;
139-
if (!debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops))
140-
goto error;
141-
142-
return 0;
143-
144-
error:
145-
debugfs_remove_recursive(acpi_ec_debugfs_dir);
146-
return -ENOMEM;
129+
debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops);
147130
}
148131

149132
static int __init acpi_ec_sys_init(void)
150133
{
151-
int err = 0;
152134
if (first_ec)
153-
err = acpi_ec_add_debugfs(first_ec, 0);
154-
else
155-
err = -ENODEV;
156-
return err;
135+
acpi_ec_add_debugfs(first_ec, 0);
136+
return 0;
157137
}
158138

159139
static void __exit acpi_ec_sys_exit(void)

0 commit comments

Comments
 (0)