PCI/AER: Add a TLP header print helper

... and call it instead of duplicating the large printk format
statement.

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Borislav Petkov 2013-12-13 14:39:56 -07:00 committed by Bjorn Helgaas
parent 6ce4eac1f6
commit fab4c256a5

View File

@ -124,6 +124,21 @@ static const char *aer_agent_string[] = {
"Transmitter ID" "Transmitter ID"
}; };
static void __print_tlp_header(struct pci_dev *dev,
struct aer_header_log_regs *t)
{
unsigned char *tlp = (unsigned char *)&t;
dev_err(&dev->dev, " TLP Header:"
" %02x%02x%02x%02x %02x%02x%02x%02x"
" %02x%02x%02x%02x %02x%02x%02x%02x\n",
*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
*(tlp + 11), *(tlp + 10), *(tlp + 9),
*(tlp + 8), *(tlp + 15), *(tlp + 14),
*(tlp + 13), *(tlp + 12));
}
static void __aer_print_error(struct pci_dev *dev, static void __aer_print_error(struct pci_dev *dev,
struct aer_err_info *info) struct aer_err_info *info)
{ {
@ -178,17 +193,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
__aer_print_error(dev, info); __aer_print_error(dev, info);
if (info->tlp_header_valid) { if (info->tlp_header_valid)
unsigned char *tlp = (unsigned char *) &info->tlp; __print_tlp_header(dev, &info->tlp);
dev_err(&dev->dev, " TLP Header:"
" %02x%02x%02x%02x %02x%02x%02x%02x"
" %02x%02x%02x%02x %02x%02x%02x%02x\n",
*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
*(tlp + 11), *(tlp + 10), *(tlp + 9),
*(tlp + 8), *(tlp + 15), *(tlp + 14),
*(tlp + 13), *(tlp + 12));
}
} }
if (info->id && info->error_dev_num > 1 && info->id == id) if (info->id && info->error_dev_num > 1 && info->id == id)
@ -250,18 +256,10 @@ void cper_print_aer(struct pci_dev *dev, int cper_severity,
if (aer_severity != AER_CORRECTABLE) if (aer_severity != AER_CORRECTABLE)
dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n", dev_err(&dev->dev, "aer_uncor_severity: 0x%08x\n",
aer->uncor_severity); aer->uncor_severity);
if (tlp_header_valid) {
const unsigned char *tlp; if (tlp_header_valid)
tlp = (const unsigned char *)&aer->header_log; __print_tlp_header(dev, &aer->header_log);
dev_err(&dev->dev, "aer_tlp_header:"
" %02x%02x%02x%02x %02x%02x%02x%02x"
" %02x%02x%02x%02x %02x%02x%02x%02x\n",
*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
*(tlp + 11), *(tlp + 10), *(tlp + 9),
*(tlp + 8), *(tlp + 15), *(tlp + 14),
*(tlp + 13), *(tlp + 12));
}
trace_aer_event(dev_name(&dev->dev), (status & ~mask), trace_aer_event(dev_name(&dev->dev), (status & ~mask),
aer_severity); aer_severity);
} }