Re: [PATCH 1/2 v2] efi: add a function to convert the status code to a string

From: Joey Lee
Date: Fri Dec 13 2019 - 05:36:44 EST


On Fri, Dec 13, 2019 at 10:03:27AM +0000, Ard Biesheuvel wrote:
> On Fri, 13 Dec 2019 at 10:07, Lee, Chun-Yi <joeyli.kernel@xxxxxxxxx> wrote:
> >
> > This function can be used to convert EFI status code to a string
> > to improve the readability of log.
> >
> > v2:
> > Moved the convert function to efi.c
> >
>
> Please put the patch series revision log below the ---

OK! I will move to below the --- next time.

>
> > Signed-off-by: "Lee, Chun-Yi" <jlee@xxxxxxxx>
>
> Acked-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
>

Thanks for your review!

> > ---
v2:
Moved the convert function to efi.c
> > drivers/firmware/efi/efi.c | 32 ++++++++++++++++++++++++++++++++
> > include/linux/efi.h | 1 +
> > 2 files changed, 33 insertions(+)

Do you mean move the revision log to here like the above?

Thanks a lot!
Joey Lee

> >
> > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> > index e98bbf8e56d9..8bdc1c17eb5d 100644
> > --- a/drivers/firmware/efi/efi.c
> > +++ b/drivers/firmware/efi/efi.c
> > @@ -954,6 +954,38 @@ int efi_status_to_err(efi_status_t status)
> > return err;
> > }
> >
> > +#define EFI_STATUS_STR(_status) \
> > + EFI_##_status : return "EFI_" __stringify(_status)
> > +
> > +const char *efi_status_to_str(efi_status_t status)
> > +{
> > + switch (status) {
> > + case EFI_STATUS_STR(SUCCESS);
> > + case EFI_STATUS_STR(LOAD_ERROR);
> > + case EFI_STATUS_STR(INVALID_PARAMETER);
> > + case EFI_STATUS_STR(UNSUPPORTED);
> > + case EFI_STATUS_STR(BAD_BUFFER_SIZE);
> > + case EFI_STATUS_STR(BUFFER_TOO_SMALL);
> > + case EFI_STATUS_STR(NOT_READY);
> > + case EFI_STATUS_STR(DEVICE_ERROR);
> > + case EFI_STATUS_STR(WRITE_PROTECTED);
> > + case EFI_STATUS_STR(OUT_OF_RESOURCES);
> > + case EFI_STATUS_STR(NOT_FOUND);
> > + case EFI_STATUS_STR(ABORTED);
> > + case EFI_STATUS_STR(SECURITY_VIOLATION);
> > + }
> > + /*
> > + * There are two possibilities for this message to be exposed:
> > + * - Caller feeds a unknown status code from firmware.
> > + * - A new status code be defined in efi.h but we forgot to update
> > + * this function.
> > + */
> > + pr_warn("Unknown efi status: 0x%lx\n", status);
> > +
> > + return "Unknown efi status";
> > +}
> > +EXPORT_SYMBOL(efi_status_to_str);
> > +
> > static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock);
> > static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init;
> >
> > diff --git a/include/linux/efi.h b/include/linux/efi.h
> > index d87acf62958e..2c6848d2b112 100644
> > --- a/include/linux/efi.h
> > +++ b/include/linux/efi.h
> > @@ -1228,6 +1228,7 @@ efi_capsule_pending(int *reset_type)
> > #endif
> >
> > extern int efi_status_to_err(efi_status_t status);
> > +extern const char *efi_status_to_str(efi_status_t status);
> >
> > /*
> > * Variable Attributes
> > --
> > 2.16.4
> >