Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbcD1KlW (ORCPT ); Thu, 28 Apr 2016 06:41:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48032 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbcD1KlU (ORCPT ); Thu, 28 Apr 2016 06:41:20 -0400 Date: Thu, 28 Apr 2016 03:40:24 -0700 From: tip-bot for Matt Fleming Message-ID: Cc: jlee@suse.com, matt@codeblueprint.co.uk, tglx@linutronix.de, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com, hock.leong.kweh@intel.com, peterz@infradead.org, bp@alien8.de Reply-To: jlee@suse.com, matt@codeblueprint.co.uk, tglx@linutronix.de, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com, hock.leong.kweh@intel.com, bp@alien8.de, peterz@infradead.org In-Reply-To: <1461614832-17633-27-git-send-email-matt@codeblueprint.co.uk> References: <1461614832-17633-27-git-send-email-matt@codeblueprint.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi: Move efi_status_to_err() to drivers/firmware/efi/ Git-Commit-ID: 806b0351c9ff9890c1ef0ba2c46237baef49ac79 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3308 Lines: 127 Commit-ID: 806b0351c9ff9890c1ef0ba2c46237baef49ac79 Gitweb: http://git.kernel.org/tip/806b0351c9ff9890c1ef0ba2c46237baef49ac79 Author: Matt Fleming AuthorDate: Mon, 25 Apr 2016 21:06:58 +0100 Committer: Ingo Molnar CommitDate: Thu, 28 Apr 2016 11:34:03 +0200 efi: Move efi_status_to_err() to drivers/firmware/efi/ Move efi_status_to_err() to the architecture independent code as it's generally useful in all bits of EFI code where there is a need to convert an efi_status_t to a kernel error value. Signed-off-by: Matt Fleming Acked-by: Ard Biesheuvel Cc: Borislav Petkov Cc: Kweh Hock Leong Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: joeyli Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1461614832-17633-27-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar --- drivers/firmware/efi/efi.c | 33 +++++++++++++++++++++++++++++++++ drivers/firmware/efi/vars.c | 33 --------------------------------- include/linux/efi.h | 2 ++ 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 4991371..05509f3 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -636,3 +636,36 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr) } return 0; } + +int efi_status_to_err(efi_status_t status) +{ + int err; + + switch (status) { + case EFI_SUCCESS: + err = 0; + break; + case EFI_INVALID_PARAMETER: + err = -EINVAL; + break; + case EFI_OUT_OF_RESOURCES: + err = -ENOSPC; + break; + case EFI_DEVICE_ERROR: + err = -EIO; + break; + case EFI_WRITE_PROTECTED: + err = -EROFS; + break; + case EFI_SECURITY_VIOLATION: + err = -EACCES; + break; + case EFI_NOT_FOUND: + err = -ENOENT; + break; + default: + err = -EINVAL; + } + + return err; +} diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 34b7419..0012331 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -329,39 +329,6 @@ check_var_size_nonblocking(u32 attributes, unsigned long size) return fops->query_variable_store(attributes, size, true); } -static int efi_status_to_err(efi_status_t status) -{ - int err; - - switch (status) { - case EFI_SUCCESS: - err = 0; - break; - case EFI_INVALID_PARAMETER: - err = -EINVAL; - break; - case EFI_OUT_OF_RESOURCES: - err = -ENOSPC; - break; - case EFI_DEVICE_ERROR: - err = -EIO; - break; - case EFI_WRITE_PROTECTED: - err = -EROFS; - break; - case EFI_SECURITY_VIOLATION: - err = -EACCES; - break; - case EFI_NOT_FOUND: - err = -ENOENT; - break; - default: - err = -EINVAL; - } - - return err; -} - static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, struct list_head *head) { diff --git a/include/linux/efi.h b/include/linux/efi.h index 4db7052..ca47481 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1080,6 +1080,8 @@ static inline void efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {} #endif +extern int efi_status_to_err(efi_status_t status); + /* * Variable Attributes */