[Skiboot] [PATCH 2/5] nvram: add nvram_query_eq()

Stewart Smith stewart at linux.vnet.ibm.com
Fri Oct 14 17:01:30 AEDT 2016


From: Oliver O'Halloran <oohall at gmail.com>

Adds a helper that looks for the given NVRAM config string and checks
that associated value is equal to the supplied value.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 core/nvram-format.c | 11 +++++++++++
 include/nvram.h     |  1 +
 2 files changed, 12 insertions(+)

diff --git a/core/nvram-format.c b/core/nvram-format.c
index b98aee1430ff..b110d804ffb7 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -262,3 +262,14 @@ const char *nvram_query(const char *key)
 
 	return NULL;
 }
+
+
+bool nvram_query_eq(const char *key, const char *value)
+{
+	const char *s = nvram_query(key);
+
+	if (!s)
+		return false;
+
+	return !strcmp(s, value);
+}
diff --git a/include/nvram.h b/include/nvram.h
index d87561d79397..288b536827b5 100644
--- a/include/nvram.h
+++ b/include/nvram.h
@@ -23,5 +23,6 @@ void nvram_reinit(void);
 bool nvram_validate(void);
 
 const char *nvram_query(const char *name);
+bool nvram_query_eq(const char *key, const char *value);
 
 #endif /* __NVRAM_H */
-- 
2.1.4



More information about the Skiboot mailing list