Skip to content

Commit e54b1dc

Browse files
zaidal-ampererafaeljw
authored andcommitted
ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type()
A single call to einj_get_available_error_type() in init function is sufficient to save the return value in a global variable to be used later in various places in the code. This change has no functional impact, but only removes unnecessary redundant function calls. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Zaid Alali <zaidal@os.amperecomputing.com> Link: https://patch.msgid.link/20250506213814.2365788-5-zaidal@os.amperecomputing.com [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 368604c commit e54b1dc

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/acpi/apei/einj-core.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static struct debugfs_blob_wrapper vendor_blob;
8383
static struct debugfs_blob_wrapper vendor_errors;
8484
static char vendor_dev[64];
8585

86+
static u32 available_error_type;
87+
8688
/*
8789
* Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the
8890
* EINJ table through an unpublished extension. Use with caution as
@@ -648,14 +650,9 @@ static struct { u32 mask; const char *str; } const einj_error_type_string[] = {
648650

649651
static int available_error_type_show(struct seq_file *m, void *v)
650652
{
651-
int rc;
652-
u32 error_type = 0;
653653

654-
rc = einj_get_available_error_type(&error_type);
655-
if (rc)
656-
return rc;
657654
for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++)
658-
if (error_type & einj_error_type_string[pos].mask)
655+
if (available_error_type & einj_error_type_string[pos].mask)
659656
seq_printf(m, "0x%08x\t%s\n", einj_error_type_string[pos].mask,
660657
einj_error_type_string[pos].str);
661658

@@ -678,8 +675,7 @@ bool einj_is_cxl_error_type(u64 type)
678675

679676
int einj_validate_error_type(u64 type)
680677
{
681-
u32 tval, vendor, available_error_type = 0;
682-
int rc;
678+
u32 tval, vendor;
683679

684680
/* Only low 32 bits for error type are valid */
685681
if (type & GENMASK_ULL(63, 32))
@@ -695,13 +691,9 @@ int einj_validate_error_type(u64 type)
695691
/* Only one error type can be specified */
696692
if (tval & (tval - 1))
697693
return -EINVAL;
698-
if (!vendor) {
699-
rc = einj_get_available_error_type(&available_error_type);
700-
if (rc)
701-
return rc;
694+
if (!vendor)
702695
if (!(type & available_error_type))
703696
return -EINVAL;
704-
}
705697

706698
return 0;
707699
}
@@ -772,6 +764,10 @@ static int __init einj_probe(struct faux_device *fdev)
772764
goto err_put_table;
773765
}
774766

767+
rc = einj_get_available_error_type(&available_error_type);
768+
if (rc)
769+
return rc;
770+
775771
rc = -ENOMEM;
776772
einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
777773

0 commit comments

Comments
 (0)