Skip to content

Commit 87386ee

Browse files
Jay Lurafaeljw
authored andcommitted
ACPI: APEI: EINJ: Refactor available_error_type_show()
Move error type descriptions into an array and loop over error types to improve readability and maintainability. Replace seq_printf() with seq_puts() as recommended by checkpatch.pl. Signed-off-by: Jay Lu <[email protected]> Co-developed-by: Ben Cheatham <[email protected]> Signed-off-by: Ben Cheatham <[email protected]> Reviewed-by: Tony Luck <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 37ea969 commit 87386ee

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

drivers/acpi/apei/einj.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,20 @@ static u64 error_param2;
571571
static u64 error_param3;
572572
static u64 error_param4;
573573
static struct dentry *einj_debug_dir;
574+
static const char * const einj_error_type_string[] = {
575+
"0x00000001\tProcessor Correctable\n",
576+
"0x00000002\tProcessor Uncorrectable non-fatal\n",
577+
"0x00000004\tProcessor Uncorrectable fatal\n",
578+
"0x00000008\tMemory Correctable\n",
579+
"0x00000010\tMemory Uncorrectable non-fatal\n",
580+
"0x00000020\tMemory Uncorrectable fatal\n",
581+
"0x00000040\tPCI Express Correctable\n",
582+
"0x00000080\tPCI Express Uncorrectable non-fatal\n",
583+
"0x00000100\tPCI Express Uncorrectable fatal\n",
584+
"0x00000200\tPlatform Correctable\n",
585+
"0x00000400\tPlatform Uncorrectable non-fatal\n",
586+
"0x00000800\tPlatform Uncorrectable fatal\n",
587+
};
574588

575589
static int available_error_type_show(struct seq_file *m, void *v)
576590
{
@@ -580,30 +594,9 @@ static int available_error_type_show(struct seq_file *m, void *v)
580594
rc = einj_get_available_error_type(&available_error_type);
581595
if (rc)
582596
return rc;
583-
if (available_error_type & 0x0001)
584-
seq_printf(m, "0x00000001\tProcessor Correctable\n");
585-
if (available_error_type & 0x0002)
586-
seq_printf(m, "0x00000002\tProcessor Uncorrectable non-fatal\n");
587-
if (available_error_type & 0x0004)
588-
seq_printf(m, "0x00000004\tProcessor Uncorrectable fatal\n");
589-
if (available_error_type & 0x0008)
590-
seq_printf(m, "0x00000008\tMemory Correctable\n");
591-
if (available_error_type & 0x0010)
592-
seq_printf(m, "0x00000010\tMemory Uncorrectable non-fatal\n");
593-
if (available_error_type & 0x0020)
594-
seq_printf(m, "0x00000020\tMemory Uncorrectable fatal\n");
595-
if (available_error_type & 0x0040)
596-
seq_printf(m, "0x00000040\tPCI Express Correctable\n");
597-
if (available_error_type & 0x0080)
598-
seq_printf(m, "0x00000080\tPCI Express Uncorrectable non-fatal\n");
599-
if (available_error_type & 0x0100)
600-
seq_printf(m, "0x00000100\tPCI Express Uncorrectable fatal\n");
601-
if (available_error_type & 0x0200)
602-
seq_printf(m, "0x00000200\tPlatform Correctable\n");
603-
if (available_error_type & 0x0400)
604-
seq_printf(m, "0x00000400\tPlatform Uncorrectable non-fatal\n");
605-
if (available_error_type & 0x0800)
606-
seq_printf(m, "0x00000800\tPlatform Uncorrectable fatal\n");
597+
for (int pos = 0; pos < ARRAY_SIZE(einj_error_type_string); pos++)
598+
if (available_error_type & BIT(pos))
599+
seq_puts(m, einj_error_type_string[pos]);
607600

608601
return 0;
609602
}

0 commit comments

Comments
 (0)