Skip to content

Commit 0678e31

Browse files
committed
PCI/AER: Simplify __aer_print_error()
aer_correctable_error_string[] and aer_uncorrectable_error_string[] have descriptions of AER error status bits. Add NULL entries to these tables so all entries for bits 0-31 are defined. Then we don't have to check for ARRAY_SIZE() when decoding a status word, which simplifies __aer_print_error(). Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 16d79cd commit 0678e31

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

drivers/pci/pcie/aer.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ static const char *aer_error_layer[] = {
447447
"Transaction Layer"
448448
};
449449

450-
static const char *aer_correctable_error_string[AER_MAX_TYPEOF_COR_ERRS] = {
450+
static const char *aer_correctable_error_string[] = {
451451
"RxErr", /* Bit Position 0 */
452452
NULL,
453453
NULL,
@@ -464,9 +464,25 @@ static const char *aer_correctable_error_string[AER_MAX_TYPEOF_COR_ERRS] = {
464464
"NonFatalErr", /* Bit Position 13 */
465465
"CorrIntErr", /* Bit Position 14 */
466466
"HeaderOF", /* Bit Position 15 */
467+
NULL, /* Bit Position 16 */
468+
NULL, /* Bit Position 17 */
469+
NULL, /* Bit Position 18 */
470+
NULL, /* Bit Position 19 */
471+
NULL, /* Bit Position 20 */
472+
NULL, /* Bit Position 21 */
473+
NULL, /* Bit Position 22 */
474+
NULL, /* Bit Position 23 */
475+
NULL, /* Bit Position 24 */
476+
NULL, /* Bit Position 25 */
477+
NULL, /* Bit Position 26 */
478+
NULL, /* Bit Position 27 */
479+
NULL, /* Bit Position 28 */
480+
NULL, /* Bit Position 29 */
481+
NULL, /* Bit Position 30 */
482+
NULL, /* Bit Position 31 */
467483
};
468484

469-
static const char *aer_uncorrectable_error_string[AER_MAX_TYPEOF_UNCOR_ERRS] = {
485+
static const char *aer_uncorrectable_error_string[] = {
470486
"Undefined", /* Bit Position 0 */
471487
NULL,
472488
NULL,
@@ -494,6 +510,11 @@ static const char *aer_uncorrectable_error_string[AER_MAX_TYPEOF_UNCOR_ERRS] = {
494510
"AtomicOpBlocked", /* Bit Position 24 */
495511
"TLPBlockedErr", /* Bit Position 25 */
496512
"PoisonTLPBlocked", /* Bit Position 26 */
513+
NULL, /* Bit Position 27 */
514+
NULL, /* Bit Position 28 */
515+
NULL, /* Bit Position 29 */
516+
NULL, /* Bit Position 30 */
517+
NULL, /* Bit Position 31 */
497518
};
498519

499520
static const char *aer_agent_string[] = {
@@ -650,24 +671,23 @@ static void __print_tlp_header(struct pci_dev *dev,
650671
static void __aer_print_error(struct pci_dev *dev,
651672
struct aer_err_info *info)
652673
{
674+
const char **strings;
653675
unsigned long status = info->status & ~info->mask;
654-
const char *errmsg = NULL;
676+
const char *errmsg;
655677
int i;
656678

679+
if (info->severity == AER_CORRECTABLE)
680+
strings = aer_correctable_error_string;
681+
else
682+
strings = aer_uncorrectable_error_string;
683+
657684
for_each_set_bit(i, &status, 32) {
658-
if (info->severity == AER_CORRECTABLE)
659-
errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
660-
aer_correctable_error_string[i] : NULL;
661-
else
662-
errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
663-
aer_uncorrectable_error_string[i] : NULL;
685+
errmsg = strings[i];
686+
if (!errmsg)
687+
errmsg = "Unknown Error Bit";
664688

665-
if (errmsg)
666-
pci_err(dev, " [%2d] %-22s%s\n", i, errmsg,
689+
pci_err(dev, " [%2d] %-22s%s\n", i, errmsg,
667690
info->first_error == i ? " (First)" : "");
668-
else
669-
pci_err(dev, " [%2d] Unknown Error Bit%s\n",
670-
i, info->first_error == i ? " (First)" : "");
671691
}
672692
pci_dev_aer_stats_incr(dev, info);
673693
}

0 commit comments

Comments
 (0)