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>
This commit is contained in:
Greg Kroah-Hartman 2019-01-22 16:21:03 +01:00 committed by Rafael J. Wysocki
parent 49a57857ae
commit 9ec6dbfbdc
4 changed files with 32 additions and 111 deletions

View File

@ -752,11 +752,6 @@ int __init acpi_aml_init(void)
{ {
int ret = 0; int ret = 0;
if (!acpi_debugfs_dir) {
ret = -ENOENT;
goto err_exit;
}
/* Initialize AML IO interface */ /* Initialize AML IO interface */
mutex_init(&acpi_aml_io.lock); mutex_init(&acpi_aml_io.lock);
init_waitqueue_head(&acpi_aml_io.wait); init_waitqueue_head(&acpi_aml_io.wait);
@ -766,10 +761,6 @@ int __init acpi_aml_init(void)
S_IFREG | S_IRUGO | S_IWUSR, S_IFREG | S_IRUGO | S_IWUSR,
acpi_debugfs_dir, NULL, acpi_debugfs_dir, NULL,
&acpi_aml_operations); &acpi_aml_operations);
if (acpi_aml_dentry == NULL) {
ret = -ENODEV;
goto err_exit;
}
ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger); ret = acpi_register_debugger(THIS_MODULE, &acpi_aml_debugger);
if (ret) if (ret)
goto err_fs; goto err_fs;
@ -788,10 +779,8 @@ void __exit acpi_aml_exit(void)
{ {
if (acpi_aml_initialized) { if (acpi_aml_initialized) {
acpi_unregister_debugger(&acpi_aml_debugger); acpi_unregister_debugger(&acpi_aml_debugger);
if (acpi_aml_dentry) { debugfs_remove(acpi_aml_dentry);
debugfs_remove(acpi_aml_dentry); acpi_aml_dentry = NULL;
acpi_aml_dentry = NULL;
}
acpi_aml_initialized = false; acpi_aml_initialized = false;
} }
} }

View File

@ -679,7 +679,6 @@ static int __init einj_init(void)
{ {
int rc; int rc;
acpi_status status; acpi_status status;
struct dentry *fentry;
struct apei_exec_context ctx; struct apei_exec_context ctx;
if (acpi_disabled) { if (acpi_disabled) {
@ -707,25 +706,13 @@ static int __init einj_init(void)
rc = -ENOMEM; rc = -ENOMEM;
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir()); einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
if (!einj_debug_dir) {
pr_err("Error creating debugfs node.\n");
goto err_cleanup;
}
fentry = debugfs_create_file("available_error_type", S_IRUSR, debugfs_create_file("available_error_type", S_IRUSR, einj_debug_dir,
einj_debug_dir, NULL, NULL, &available_error_type_fops);
&available_error_type_fops); debugfs_create_file("error_type", S_IRUSR | S_IWUSR, einj_debug_dir,
if (!fentry) NULL, &error_type_fops);
goto err_cleanup; debugfs_create_file("error_inject", S_IWUSR, einj_debug_dir,
NULL, &error_inject_fops);
fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
einj_debug_dir, NULL, &error_type_fops);
if (!fentry)
goto err_cleanup;
fentry = debugfs_create_file("error_inject", S_IWUSR,
einj_debug_dir, NULL, &error_inject_fops);
if (!fentry)
goto err_cleanup;
apei_resources_init(&einj_resources); apei_resources_init(&einj_resources);
einj_exec_ctx_init(&ctx); einj_exec_ctx_init(&ctx);
@ -750,66 +737,37 @@ static int __init einj_init(void)
rc = -ENOMEM; rc = -ENOMEM;
einj_param = einj_get_parameter_address(); einj_param = einj_get_parameter_address();
if ((param_extension || acpi5) && einj_param) { if ((param_extension || acpi5) && einj_param) {
fentry = debugfs_create_x32("flags", S_IRUSR | S_IWUSR, debugfs_create_x32("flags", S_IRUSR | S_IWUSR, einj_debug_dir,
einj_debug_dir, &error_flags); &error_flags);
if (!fentry) debugfs_create_x64("param1", S_IRUSR | S_IWUSR, einj_debug_dir,
goto err_unmap; &error_param1);
fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, debugfs_create_x64("param2", S_IRUSR | S_IWUSR, einj_debug_dir,
einj_debug_dir, &error_param1); &error_param2);
if (!fentry) debugfs_create_x64("param3", S_IRUSR | S_IWUSR, einj_debug_dir,
goto err_unmap; &error_param3);
fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, debugfs_create_x64("param4", S_IRUSR | S_IWUSR, einj_debug_dir,
einj_debug_dir, &error_param2); &error_param4);
if (!fentry) debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
goto err_unmap; einj_debug_dir, &notrigger);
fentry = debugfs_create_x64("param3", S_IRUSR | S_IWUSR,
einj_debug_dir, &error_param3);
if (!fentry)
goto err_unmap;
fentry = debugfs_create_x64("param4", S_IRUSR | S_IWUSR,
einj_debug_dir, &error_param4);
if (!fentry)
goto err_unmap;
fentry = debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
einj_debug_dir, &notrigger);
if (!fentry)
goto err_unmap;
} }
if (vendor_dev[0]) { if (vendor_dev[0]) {
vendor_blob.data = vendor_dev; vendor_blob.data = vendor_dev;
vendor_blob.size = strlen(vendor_dev); vendor_blob.size = strlen(vendor_dev);
fentry = debugfs_create_blob("vendor", S_IRUSR, debugfs_create_blob("vendor", S_IRUSR, einj_debug_dir,
einj_debug_dir, &vendor_blob); &vendor_blob);
if (!fentry) debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
goto err_unmap; einj_debug_dir, &vendor_flags);
fentry = debugfs_create_x32("vendor_flags", S_IRUSR | S_IWUSR,
einj_debug_dir, &vendor_flags);
if (!fentry)
goto err_unmap;
} }
pr_info("Error INJection is initialized.\n"); pr_info("Error INJection is initialized.\n");
return 0; return 0;
err_unmap:
if (einj_param) {
acpi_size size = (acpi5) ?
sizeof(struct set_error_type_with_address) :
sizeof(struct einj_parameter);
acpi_os_unmap_iomem(einj_param, size);
pr_err("Error creating param extension debugfs nodes.\n");
}
apei_exec_post_unmap_gars(&ctx);
err_release: err_release:
apei_resources_release(&einj_resources); apei_resources_release(&einj_resources);
err_fini: err_fini:
apei_resources_fini(&einj_resources); apei_resources_fini(&einj_resources);
err_cleanup:
pr_err("Error creating primary debugfs nodes.\n");
debugfs_remove_recursive(einj_debug_dir); debugfs_remove_recursive(einj_debug_dir);
return rc; return rc;

View File

@ -79,14 +79,8 @@ static const struct file_operations cm_fops = {
static int __init acpi_custom_method_init(void) static int __init acpi_custom_method_init(void)
{ {
if (acpi_debugfs_dir == NULL)
return -ENOENT;
cm_dentry = debugfs_create_file("custom_method", S_IWUSR, cm_dentry = debugfs_create_file("custom_method", S_IWUSR,
acpi_debugfs_dir, NULL, &cm_fops); acpi_debugfs_dir, NULL, &cm_fops);
if (cm_dentry == NULL)
return -ENODEV;
return 0; return 0;
} }

View File

@ -108,52 +108,32 @@ static const struct file_operations acpi_ec_io_ops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) static void acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
{ {
struct dentry *dev_dir; struct dentry *dev_dir;
char name[64]; char name[64];
umode_t mode = 0400; umode_t mode = 0400;
if (ec_device_count == 0) { if (ec_device_count == 0)
acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL); acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL);
if (!acpi_ec_debugfs_dir)
return -ENOMEM;
}
sprintf(name, "ec%u", ec_device_count); sprintf(name, "ec%u", ec_device_count);
dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir); dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir);
if (!dev_dir) {
if (ec_device_count != 0)
goto error;
return -ENOMEM;
}
if (!debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe)) debugfs_create_x32("gpe", 0444, dev_dir, &first_ec->gpe);
goto error; debugfs_create_bool("use_global_lock", 0444, dev_dir,
if (!debugfs_create_bool("use_global_lock", 0444, dev_dir, &first_ec->global_lock);
&first_ec->global_lock))
goto error;
if (write_support) if (write_support)
mode = 0600; mode = 0600;
if (!debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops)) debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops);
goto error;
return 0;
error:
debugfs_remove_recursive(acpi_ec_debugfs_dir);
return -ENOMEM;
} }
static int __init acpi_ec_sys_init(void) static int __init acpi_ec_sys_init(void)
{ {
int err = 0;
if (first_ec) if (first_ec)
err = acpi_ec_add_debugfs(first_ec, 0); acpi_ec_add_debugfs(first_ec, 0);
else return 0;
err = -ENODEV;
return err;
} }
static void __exit acpi_ec_sys_exit(void) static void __exit acpi_ec_sys_exit(void)