Print the actual UEFI error name, not just the error code.
PATCH 1/1 Print the actual UEFI error name, not just the error code.
EFI error numbers are useful, but symbol names are way easier to understand when you're reading bug reports. And since, for the most part, we know the names, we should show them.
--- drivers/firmware/efivars.c | 19 +++++------- include/linux/efi.h | 75 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 23 deletions(-)
drivers/firmware/efivars.c +7 -12
@@ -382,8 +382,7 @@ get_var_data(struct efivars *efivars, struct efi_variable *var)spin_unlock_irqrestore (&efivars->lock, flags);if (status !=EFI_SUCCESS ) { -printk (KERN_WARNING "efivars: get_variable() failed 0x%lx!\n" , - status); +efi_pr_warn (status,"efivars: get_variable() failed" ); }return status; }
@@ -549,8 +548,7 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count)spin_unlock_irq (&efivars->lock);if (status !=EFI_SUCCESS ) { -printk (KERN_WARNING "efivars: set_variable() failed: status=%lx\n" , - status); +efi_pr_warn (status,"efivars: set_variable() failed" );return -EIO ; }
@@ -802,8 +800,8 @@ static ssize_t efivarfs_file_write(struct file *file, }else {spin_unlock_irq (&efivars->lock); -pr_warn ("efivarfs: inconsistent EFI variable implementation? " -"status = %lx\n" , status); +efi_pr_warn (status, +"efivarfs: inconsistent EFI variable implementation? " ); } out:
@@ -1549,8 +1547,7 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, new_var->Data);if (status !=EFI_SUCCESS ) { -printk (KERN_WARNING "efivars: set_variable() failed: status=%lx\n" , - status); +efi_pr_warn (status,"efivars: set_variable() failed" );spin_unlock_irq (&efivars->lock);return -EIO ; }
@@ -1614,8 +1611,7 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, del_var->Data);if (status !=EFI_SUCCESS ) { -printk (KERN_WARNING "efivars: set_variable() failed: status=%lx\n" , - status); +efi_pr_warn (status,"efivars: set_variable() failed" );spin_unlock_irq (&efivars->lock);return -EIO ; }
@@ -2023,8 +2019,7 @@ int register_efivars(struct efivars *efivars,case EFI_NOT_FOUND :break ;default : -printk (KERN_WARNING "efivars: get_next_variable: status=%lx\n" , - status); +efi_pr_warn (status,"efivars: get_next_variable" ); status =EFI_NOT_FOUND ;break ; }
include/linux/efi.h +64 -11
82 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Quoted 3 lines · Peter Jones
EFI error numbers are useful, but symbol names are way easier to understand when you're reading bug reports. And since, for the most part, we know the names, we should show them.
[]
drivers/firmware/efivars.c
Quoted 1 line
drivers/firmware/efivars.c +0
-0
[]
drivers/firmware/efivars.c
Quoted 9 lines
drivers/firmware/efivars.c +9
-0+#define efi_pr_warn (status, fmt, ...) ({ \ + typeof(status) __status = EFI_REVERSE_ERROR(status); \ + if (__status >= 0 && \ + __status <= EFI_REVERSE_ERROR(EFI_MAX_ERROR))\ + pr_warn(fmt ": %s (0x%lx)\n", ## __VA_ARGS__, \ + efi_error_strings[__status], __status); \ + else \ + pr_warn(fmt ": 0x%lx\n", ## __VA_ARGS__, __status);\ + })
This doubles the number of formats (and code size text) used.
Please don't remove trailing newlines from these sorts of messages.
I think a function to return "unknown efi error" would be acceptable and these should become something like:
const char *efi_error_string(unsigned long status)
{
if (status <= EFI_REVERSE_ERROR(EFI_MAX_ERROR))
return efi_error_strings[status];
return "unknown efi error";
}and the uses something like:
drivers/firmware/efivars.c
Quoted 2 lines
drivers/firmware/efivars.c +0
-2-printk (KERN_WARNING "efivars: set_variable() failed: status=%lx\n" , - status);
--
pr_warn("set_variable() failed: %s (%lx)\n",
efi_error_string(status), status);(with #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt)