[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKv+Gu8sGku8e1q9ku_wXfcXTGQ5W8Lt_q5KEK9WycgHw15TgA@mail.gmail.com>
Date: Fri, 13 Dec 2019 10:03:27 +0000
From: Ard Biesheuvel <ard.biesheuvel@...aro.org>
To: "Lee, Chun-Yi" <joeyli.kernel@...il.com>
Cc: James Morris <jmorris@...ei.org>,
"Serge E . Hallyn" <serge@...lyn.com>,
David Howells <dhowells@...hat.com>,
Josh Boyer <jwboyer@...oraproject.org>,
Nayna Jain <nayna@...ux.ibm.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
linux-efi <linux-efi@...r.kernel.org>,
linux-security-module <linux-security-module@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
"Lee, Chun-Yi" <jlee@...e.com>
Subject: Re: [PATCH 1/2 v2] efi: add a function to convert the status code to
a string
On Fri, 13 Dec 2019 at 10:07, Lee, Chun-Yi <joeyli.kernel@...il.com> 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 ---
> Signed-off-by: "Lee, Chun-Yi" <jlee@...e.com>
Acked-by: Ard Biesheuvel <ardb@...nel.org>
> ---
> drivers/firmware/efi/efi.c | 32 ++++++++++++++++++++++++++++++++
> include/linux/efi.h | 1 +
> 2 files changed, 33 insertions(+)
>
> 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
>
Powered by blists - more mailing lists