Skip to content

Commit dba6483

Browse files
suryasaimadhurafaeljw
authored andcommitted
ACPI / einj: Make error paths more talkative
It is absolutely unfriendly when one sees this: # modprobe einj modprobe: ERROR: could not insert 'einj': No such device without anything in dmesg to tell one why the load failed. Beef up the error handling of the init function to be more user-friendly when the load fails. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Tony Luck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent b2f740b commit dba6483

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

drivers/acpi/apei/einj.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -692,34 +692,42 @@ static int __init einj_init(void)
692692
struct dentry *fentry;
693693
struct apei_exec_context ctx;
694694

695-
if (acpi_disabled)
695+
if (acpi_disabled) {
696+
pr_warn("ACPI disabled.\n");
696697
return -ENODEV;
698+
}
697699

698700
status = acpi_get_table(ACPI_SIG_EINJ, 0,
699701
(struct acpi_table_header **)&einj_tab);
700-
if (status == AE_NOT_FOUND)
702+
if (status == AE_NOT_FOUND) {
703+
pr_warn("EINJ table not found.\n");
701704
return -ENODEV;
705+
}
702706
else if (ACPI_FAILURE(status)) {
703-
const char *msg = acpi_format_exception(status);
704-
pr_err("Failed to get table, %s\n", msg);
707+
pr_err("Failed to get EINJ table: %s\n",
708+
acpi_format_exception(status));
705709
return -EINVAL;
706710
}
707711

708712
rc = einj_check_table(einj_tab);
709713
if (rc) {
710-
pr_warning(FW_BUG "EINJ table is invalid\n");
714+
pr_warn(FW_BUG "Invalid EINJ table.n");
711715
return -EINVAL;
712716
}
713717

714718
rc = -ENOMEM;
715719
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
716-
if (!einj_debug_dir)
720+
if (!einj_debug_dir) {
721+
pr_err("Error creating debugfs node.\n");
717722
goto err_cleanup;
723+
}
724+
718725
fentry = debugfs_create_file("available_error_type", S_IRUSR,
719726
einj_debug_dir, NULL,
720727
&available_error_type_fops);
721728
if (!fentry)
722729
goto err_cleanup;
730+
723731
fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
724732
einj_debug_dir, NULL, &error_type_fops);
725733
if (!fentry)
@@ -732,14 +740,22 @@ static int __init einj_init(void)
732740
apei_resources_init(&einj_resources);
733741
einj_exec_ctx_init(&ctx);
734742
rc = apei_exec_collect_resources(&ctx, &einj_resources);
735-
if (rc)
743+
if (rc) {
744+
pr_err("Error collecting EINJ resources.\n");
736745
goto err_fini;
746+
}
747+
737748
rc = apei_resources_request(&einj_resources, "APEI EINJ");
738-
if (rc)
749+
if (rc) {
750+
pr_err("Error requesting memory/port resources.\n");
739751
goto err_fini;
752+
}
753+
740754
rc = apei_exec_pre_map_gars(&ctx);
741-
if (rc)
755+
if (rc) {
756+
pr_err("Error pre-mapping GARs.\n");
742757
goto err_release;
758+
}
743759

744760
rc = -ENOMEM;
745761
einj_param = einj_get_parameter_address();
@@ -795,13 +811,15 @@ static int __init einj_init(void)
795811
sizeof(struct einj_parameter);
796812

797813
acpi_os_unmap_iomem(einj_param, size);
814+
pr_err("Error creating param extension debugfs nodes.\n");
798815
}
799816
apei_exec_post_unmap_gars(&ctx);
800817
err_release:
801818
apei_resources_release(&einj_resources);
802819
err_fini:
803820
apei_resources_fini(&einj_resources);
804821
err_cleanup:
822+
pr_err("Error creating primary debugfs nodes.\n");
805823
debugfs_remove_recursive(einj_debug_dir);
806824

807825
return rc;

0 commit comments

Comments
 (0)