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

Oliver O'Halloran oohall at gmail.com
Wed Sep 28 14:56:30 AEST 2016


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



More information about the Skiboot mailing list