diff mbox series

[v2] ACPI / APEI: Add is_generic_error() to identify GHES sources

Message ID 20210126163201.1433505-1-terry.bowman@amd.com (mailing list archive)
State Mainlined, archived
Headers show
Series [v2] ACPI / APEI: Add is_generic_error() to identify GHES sources | expand

Commit Message

Terry Bowman Jan. 26, 2021, 4:32 p.m. UTC
From: Yazen Ghannam <yazen.ghannam@amd.com>

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>
---
Changes in v2:
  - Rename is_ghes_type() to is_generic_error()
  - Add co-developed-by
  
 drivers/acpi/apei/hest.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

2.27.0

Comments

Borislav Petkov Jan. 26, 2021, 4:44 p.m. UTC | #1
On Tue, Jan 26, 2021 at 10:32:01AM -0600, Terry Bowman wrote:
> From: Yazen Ghannam <yazen.ghannam@amd.com>
> 
> 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>
> ---
> Changes in v2:
>   - Rename is_ghes_type() to is_generic_error()
>   - Add co-developed-by
>   
>  drivers/acpi/apei/hest.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
> index 6e980fe16772..f220bb00e91b 100644
> --- a/drivers/acpi/apei/hest.c
> +++ b/drivers/acpi/apei/hest.c
> @@ -49,6 +49,12 @@ static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
>  	[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)
>  {
>  	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;
>  
> -	if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
> -	    hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2)
> +	if (is_generic_error(hest_hdr))
>  		(*count)++;
>  	return 0;
>  }
> @@ -153,9 +158,7 @@ static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
>  	struct ghes_arr *ghes_arr = data;
>  	int rc, i;
>  
> -	if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR &&
> -	    hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
> +	if (!is_generic_error(hest_hdr))
>  		return 0;
>  
>  	if (!((struct acpi_hest_generic *)hest_hdr)->enabled)
> --

Acked-by: Borislav Petkov <bp@suse.de>
Rafael J. Wysocki Jan. 27, 2021, 6:03 p.m. UTC | #2
On Tue, Jan 26, 2021 at 11:48 PM Borislav Petkov <bp@alien8.de> wrote:
>
> On Tue, Jan 26, 2021 at 10:32:01AM -0600, Terry Bowman wrote:
> > From: Yazen Ghannam <yazen.ghannam@amd.com>
> >
> > 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>
> > ---
> > Changes in v2:
> >   - Rename is_ghes_type() to is_generic_error()
> >   - Add co-developed-by
> >
> >  drivers/acpi/apei/hest.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
> > index 6e980fe16772..f220bb00e91b 100644
> > --- a/drivers/acpi/apei/hest.c
> > +++ b/drivers/acpi/apei/hest.c
> > @@ -49,6 +49,12 @@ static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
> >       [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)
> >  {
> >       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;
> >
> > -     if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
> > -         hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2)
> > +     if (is_generic_error(hest_hdr))
> >               (*count)++;
> >       return 0;
> >  }
> > @@ -153,9 +158,7 @@ static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
> >       struct ghes_arr *ghes_arr = data;
> >       int rc, i;
> >
> > -     if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR &&
> > -         hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
> > +     if (!is_generic_error(hest_hdr))
> >               return 0;
> >
> >       if (!((struct acpi_hest_generic *)hest_hdr)->enabled)
> > --
>
> Acked-by: Borislav Petkov <bp@suse.de>

Applied as 5.12 material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 6e980fe16772..f220bb00e91b 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -49,6 +49,12 @@  static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
 	[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)
 {
 	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;
 
-	if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
-	    hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2)
+	if (is_generic_error(hest_hdr))
 		(*count)++;
 	return 0;
 }
@@ -153,9 +158,7 @@  static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
 	struct ghes_arr *ghes_arr = data;
 	int rc, i;
 
-	if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR &&
-	    hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
+	if (!is_generic_error(hest_hdr))
 		return 0;
 
 	if (!((struct acpi_hest_generic *)hest_hdr)->enabled)
--