[U-Boot] [RFC, PATCH v4 07/16] env: add/expose attribute helper functions for hashtable

AKASHI Takahiro takahiro.akashi at linaro.org
Wed Jul 17 08:25:16 UTC 2019


Those functions will be used for hashtable routines to support attributes
in importing/exporting entries.

Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 env/flags.c         | 19 +++++++++++++++++--
 include/env_flags.h | 10 ++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/env/flags.c b/env/flags.c
index c1db891a2343..1a1872aa2fc7 100644
--- a/env/flags.c
+++ b/env/flags.c
@@ -238,6 +238,21 @@ enum env_flags_varstorage env_flags_parse_varstorage_from_binflags(int binflags)
 	return env_flags_varstorage_non_volatile;
 }
 
+void env_flags_encode_attr_from_binflags(char *attr, int binflags)
+{
+	enum env_flags_vartype type;
+	enum env_flags_varaccess access;
+	enum env_flags_varstorage storage;
+
+	type = (enum env_flags_vartype)(binflags & ENV_FLAGS_VARTYPE_BIN_MASK);
+	access = env_flags_parse_varaccess_from_binflags(binflags);
+	storage = env_flags_parse_varstorage_from_binflags(binflags);
+
+	attr[ENV_FLAGS_VARTYPE_LOC] = env_flags_vartype_rep[type];
+	attr[ENV_FLAGS_VARACCESS_LOC] = env_flags_varaccess_rep[access];
+	attr[ENV_FLAGS_VARSTORAGE_LOC] = env_flags_varstorage_rep[storage];
+}
+
 static inline int is_hex_prefix(const char *value)
 {
 	return value[0] == '0' && (value[1] == 'x' || value[1] == 'X');
@@ -488,10 +503,10 @@ int env_flags_validate_env_set_params(char *name, char * const val[], int count)
 #else /* !USE_HOSTCC - Functions only used from lib/hashtable.c */
 
 /*
- * Parse the flag charachters from the .flags attribute list into the binary
+ * Parse the flag characters from the .flags attribute list into the binary
  * form to be stored in the environment entry->flags field.
  */
-static int env_parse_flags_to_bin(const char *flags)
+int env_parse_flags_to_bin(const char *flags)
 {
 	int binflags = 0;
 
diff --git a/include/env_flags.h b/include/env_flags.h
index f46528691889..15391a28de77 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -132,6 +132,10 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags);
  */
 enum env_flags_varstorage
 env_flags_parse_varstorage_from_binflags(int binflags);
+/*
+ * Create a string representation from the binary flags
+ */
+void env_flags_encode_attr_from_binflags(char *attr, int binflags);
 
 #ifdef CONFIG_CMD_NET
 /*
@@ -175,6 +179,12 @@ int env_flags_validate_env_set_params(char *name, char *const val[], int count);
 
 #else /* !USE_HOSTCC */
 
+/*
+ * Parse the flag characters from the .flags attribute list into the binary
+ * form to be stored in the environment entry->flags field.
+ */
+int env_parse_flags_to_bin(const char *flags);
+
 #include <search.h>
 
 /*
-- 
2.21.0



More information about the U-Boot mailing list