From: Matt Fleming <matt@console-pimps.org>
To: linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Tony Luck <tony.luck@intel.com>,
Seiji Aguchi <seiji.aguchi@hds.com>,
x86@kernel.org, Matt Fleming <matt.fleming@intel.com>
Subject: [PATCH 4/5] efi: Move efi_status_to_err() to efi.h
Date: Wed, 16 Oct 2013 14:50:59 +0100 [thread overview]
Message-ID: <1381931460-6999-5-git-send-email-matt@console-pimps.org> (raw)
In-Reply-To: <1381931460-6999-1-git-send-email-matt@console-pimps.org>
From: Matt Fleming <matt.fleming@intel.com>
Move efi_status_to_err() into the efi.h header 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 <matt.fleming@intel.com>
---
drivers/firmware/efi/vars.c | 33 ---------------------------------
include/linux/efi.h | 33 +++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index ac9a4ea..6ff19ff 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -237,39 +237,6 @@ check_var_size(u32 attributes, unsigned long size)
return fops->query_variable_store(attributes, size);
}
-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 eed69c9..6a10640 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -753,6 +753,39 @@ static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
*addr &= PAGE_MASK;
}
+static inline 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;
+}
+
/*
* EFI Variable support.
*
--
1.8.1.4
next prev parent reply other threads:[~2013-10-16 13:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 13:50 [PATCH 0/5] EFI capsule pstore support Matt Fleming
[not found] ` <1381931460-6999-1-git-send-email-matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-10-16 13:50 ` [PATCH 1/5] pstore/ftrace: Don't increment initial data offset Matt Fleming
2013-10-16 13:50 ` [PATCH 2/5] efi: Introduce a Runtime Services lock Matt Fleming
[not found] ` <1381931460-6999-3-git-send-email-matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-10-16 23:36 ` Seiji Aguchi
2013-10-16 13:50 ` [PATCH 3/5] efi: Add common efi_reboot() implementation Matt Fleming
2013-10-16 13:50 ` Matt Fleming [this message]
2013-10-16 13:51 ` [PATCH 5/5] efi: Capsule update support and pstore backend Matt Fleming
[not found] ` <1381931460-6999-6-git-send-email-matt-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-10-16 14:19 ` Matthew Garrett
[not found] ` <20131016141939.GA28684-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2013-10-16 14:52 ` Luck, Tony
[not found] ` <3908561D78D1C84285E8C5FCA982C28F31D31122-P5GAC/sN6hlZtRGVdHMbwrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-10-17 0:06 ` Seiji Aguchi
[not found] ` <A5ED84D3BB3A384992CBB9C77DEDA4D443EF862E-ohthHghroY0jroPwUH3sq+6wyyQG6/Uh@public.gmane.org>
2013-10-17 23:18 ` Andi Kleen
2013-10-17 12:05 ` Matt Fleming
2013-10-17 11:55 ` Matt Fleming
[not found] ` <20131017115514.GE10834-HNK1S37rvNbeXh+fF434Mdi2O/JbrIOy@public.gmane.org>
2013-10-17 23:19 ` Andi Kleen
2013-10-16 20:14 ` Andi Kleen
2013-10-17 12:14 ` Matt Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381931460-6999-5-git-send-email-matt@console-pimps.org \
--to=matt@console-pimps.org \
--cc=ak@linux.intel.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=seiji.aguchi@hds.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).