linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Shorten constant names for EFI variable attributes
@ 2012-07-20 22:08 Khalid Aziz
  2012-07-20 22:10 ` H. Peter Anvin
  0 siblings, 1 reply; 12+ messages in thread
From: Khalid Aziz @ 2012-07-20 22:08 UTC (permalink / raw)
  To: mjg, mikew, tony.luck, keescook, gong.chen, gregkh,
	paul.gortmaker, maxin.john, rdunlap, hpa, matt.fleming, olof,
	dhowells
  Cc: linux-kernel

Replace very long constants for EFI variable attributes
with shorter and more convenient names. Also create an
alias for the current longer names so as to not break
compatibility with current API since these constants
are used by userspace programs. This patch depends on 
patch <https://lkml.org/lkml/2012/7/13/313>.


Signed-off-by: Khalid Aziz <khalid.aziz@hp.com>
---
 drivers/firmware/efivars.c     |   20 ++++++++------------
 drivers/firmware/google/gsmi.c |    8 ++------
 include/linux/efi.h            |   35 ++++++++++++++++++++---------------
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index d10c987..27f4fab 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -122,10 +122,7 @@ struct efivar_attribute {
 	ssize_t (*store)(struct efivar_entry *entry, const char *buf, size_t count);
 };
 
-#define PSTORE_EFI_ATTRIBUTES \
-	(EFI_VARIABLE_NON_VOLATILE | \
-	 EFI_VARIABLE_BOOTSERVICE_ACCESS | \
-	 EFI_VARIABLE_RUNTIME_ACCESS)
+#define PSTORE_EFI_ATTRIBUTES	(EFI_VAR_NV | EFI_VAR_BOOT | EFI_VAR_RUNTIME)
 
 #define EFIVAR_ATTR(_name, _mode, _show, _store) \
 struct efivar_attribute efivar_attr_##_name = { \
@@ -435,22 +432,21 @@ efivar_attr_read(struct efivar_entry *entry, char *buf)
 	if (status != EFI_SUCCESS)
 		return -EIO;
 
-	if (var->Attributes & EFI_VARIABLE_NON_VOLATILE)
+	if (var->Attributes & EFI_VAR_NV)
 		str += sprintf(str, "EFI_VARIABLE_NON_VOLATILE\n");
-	if (var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)
+	if (var->Attributes & EFI_VAR_BOOT)
 		str += sprintf(str, "EFI_VARIABLE_BOOTSERVICE_ACCESS\n");
-	if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)
+	if (var->Attributes & EFI_VAR_RUNTIME)
 		str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");
-	if (var->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD)
+	if (var->Attributes & EFI_VAR_HW_ERR)
 		str += sprintf(str, "EFI_VARIABLE_HARDWARE_ERROR_RECORD\n");
-	if (var->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)
+	if (var->Attributes & EFI_VAR_AUTH_WRITE)
 		str += sprintf(str,
 			"EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\n");
-	if (var->Attributes &
-			EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)
+	if (var->Attributes & EFI_VAR_TIMED_AUTH_WRITE)
 		str += sprintf(str,
 			"EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\n");
-	if (var->Attributes & EFI_VARIABLE_APPEND_WRITE)
+	if (var->Attributes & EFI_VAR_APPEND)
 		str += sprintf(str, "EFI_VARIABLE_APPEND_WRITE\n");
 	return str - buf;
 }
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 91ddf0f..3e2d6d4 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -353,9 +353,7 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name,
 		memcpy(data, gsmi_dev.data_buf->start, *data_size);
 
 		/* All variables are have the following attributes */
-		*attr = EFI_VARIABLE_NON_VOLATILE |
-			EFI_VARIABLE_BOOTSERVICE_ACCESS |
-			EFI_VARIABLE_RUNTIME_ACCESS;
+		*attr = EFI_VAR_NV | EFI_VAR_BOOT | EFI_VAR_RUNTIME;
 	}
 
 	spin_unlock_irqrestore(&gsmi_dev.lock, flags);
@@ -430,9 +428,7 @@ static efi_status_t gsmi_set_variable(efi_char16_t *name,
 		.name_ptr = gsmi_dev.name_buf->address,
 		.data_ptr = gsmi_dev.data_buf->address,
 		.data_len = (u32)data_size,
-		.attributes = EFI_VARIABLE_NON_VOLATILE |
-			      EFI_VARIABLE_BOOTSERVICE_ACCESS |
-			      EFI_VARIABLE_RUNTIME_ACCESS,
+		.attributes = EFI_VAR_NV | EFI_VAR_BOOT | EFI_VAR_RUNTIME,
 	};
 	size_t name_len = utf16_strlen(name, GSMI_BUF_SIZE / 2);
 	efi_status_t ret = EFI_SUCCESS;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index ec45ccd..3d2a6f0 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -551,21 +551,26 @@ extern int __init efi_setup_pcdp_console(char *);
 /*
  * Variable Attributes
  */
-#define EFI_VARIABLE_NON_VOLATILE       0x0000000000000001
-#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
-#define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
-#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
-#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
-#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
-#define EFI_VARIABLE_APPEND_WRITE	0x0000000000000040
-
-#define EFI_VARIABLE_MASK 	(EFI_VARIABLE_NON_VOLATILE | \
-				EFI_VARIABLE_BOOTSERVICE_ACCESS | \
-				EFI_VARIABLE_RUNTIME_ACCESS | \
-				EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
-				EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
-				EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
-				EFI_VARIABLE_APPEND_WRITE)
+#define EFI_VAR_NV			0x0000000000000001
+#define EFI_VAR_BOOT			0x0000000000000002
+#define EFI_VAR_RUNTIME			0x0000000000000004
+#define EFI_VAR_HW_ERR			0x0000000000000008
+#define EFI_VAR_AUTH_WRITE		0x0000000000000010
+#define EFI_VAR_TIMED_AUTH_WRITE	0x0000000000000020
+#define EFI_VAR_APPEND			0x0000000000000040
+
+#define EFI_VARIABLE_NON_VOLATILE			EFI_VAR_NV
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS			EFI_VAR_BOOT
+#define EFI_VARIABLE_RUNTIME_ACCESS			EFI_VAR_RUNTIME
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD		EFI_VAR_HW_ERR
+#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS		EFI_VAR_AUTH_WRITE
+#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS \
+							EFI_VAR_TIMED_AUTH_WRITE
+#define EFI_VARIABLE_APPEND_WRITE			EFI_VAR_APPEND
+
+#define EFI_VARIABLE_MASK	(EFI_VAR_NV | EFI_VAR_BOOT | EFI_VAR_RUNTIME | \
+				EFI_VAR_HW_ERR | EFI_VAR_AUTH_WRITE | \
+				EFI_VAR_TIMED_AUTH_WRITE | EFI_VAR_APPEND)
 /*
  * The type of search to perform when calling boottime->locate_handle
  */
-- 
1.7.9.5

-- 

===========
Khalid Aziz
khalid.aziz@hp.com

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-09-25 23:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20 22:08 [PATCH] Shorten constant names for EFI variable attributes Khalid Aziz
2012-07-20 22:10 ` H. Peter Anvin
2012-07-20 22:30   ` Khalid Aziz
2012-07-20 22:34     ` H. Peter Anvin
2012-07-20 22:46       ` Khalid Aziz
2012-07-23 13:26   ` Matthew Garrett
2012-07-26 17:28     ` Khalid Aziz
2012-07-26 17:33       ` Matthew Garrett
2012-09-25 15:41         ` [PATCH -next v2] " Khalid Aziz
2012-09-25 21:55           ` Stephen Rothwell
2012-09-25 23:06             ` Khalid Aziz
2012-09-25 23:12               ` Matthew Garrett

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).