ACPI: APEI: Add is_generic_error() to identify GHES sources

Refactor duplicated GHES identity logic into is_generic_error().

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Reviewed-by: Robert Richter <rrichter@amd.com>
Co-developed-by: Terry Bowman <terry.bowman@amd.com>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Yazen Ghannam 2021-01-26 10:32:01 -06:00 коммит произвёл Rafael J. Wysocki
Родитель 6ee1d745b7
Коммит dc20c40920
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -49,6 +49,12 @@ static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
[ACPI_HEST_TYPE_IA32_DEFERRED_CHECK] = -1, [ACPI_HEST_TYPE_IA32_DEFERRED_CHECK] = -1,
}; };
static inline bool is_generic_error(struct acpi_hest_header *hest_hdr)
{
return hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2;
}
static int hest_esrc_len(struct acpi_hest_header *hest_hdr) static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
{ {
u16 hest_type = hest_hdr->type; u16 hest_type = hest_hdr->type;
@ -141,8 +147,7 @@ static int __init hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void
{ {
int *count = data; int *count = data;
if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR || if (is_generic_error(hest_hdr))
hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2)
(*count)++; (*count)++;
return 0; return 0;
} }
@ -153,8 +158,7 @@ static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
struct ghes_arr *ghes_arr = data; struct ghes_arr *ghes_arr = data;
int rc, i; int rc, i;
if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR && if (!is_generic_error(hest_hdr))
hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
return 0; return 0;
if (!((struct acpi_hest_generic *)hest_hdr)->enabled) if (!((struct acpi_hest_generic *)hest_hdr)->enabled)