Patchwork [U-Boot,07/14] fdt: Add function to read boolean property

login
register
mail settings
Submitter Simon Glass
Date Oct. 26, 2012, 2:31 a.m.
Message ID <1351218671-15228-8-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/194337/
State Accepted, archived
Delegated to: Jerry Van Baren
Headers show

Comments

Simon Glass - Oct. 26, 2012, 2:31 a.m.
From: Gabe Black <gabeblack@chromium.org>

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Gabe Black <gabeblack@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/fdtdec.h |   10 ++++++++++
 lib/fdtdec.c     |   14 ++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

Patch

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 3f1840c..82fdb99 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -408,6 +408,16 @@  int fdtdec_get_config_int(const void *blob, const char *prop_name,
 		int default_val);
 
 /**
+ * Look in the FDT for a config item with the given name
+ * and return whether it exists.
+ *
+ * @param blob		FDT blob
+ * @param prop_name	property name to look up
+ * @return 1, if it exists, or 0 if not
+ */
+int fdtdec_get_config_bool(const void *blob, const char *prop_name);
+
+/**
  * Look in the FDT for a config item with the given name and return its value
  * as a string.
  *
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index efe9afe..fbb2827 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -524,6 +524,20 @@  int fdtdec_get_config_int(const void *blob, const char *prop_name,
 	return fdtdec_get_int(blob, config_node, prop_name, default_val);
 }
 
+int fdtdec_get_config_bool(const void *blob, const char *prop_name)
+{
+	int config_node;
+	const void *prop;
+
+	debug("%s: %s\n", __func__, prop_name);
+	config_node = fdt_path_offset(blob, "/config");
+	if (config_node < 0)
+		return 0;
+	prop = fdt_get_property(blob, config_node, prop_name, NULL);
+
+	return prop != NULL;
+}
+
 char *fdtdec_get_config_string(const void *blob, const char *prop_name)
 {
 	const char *nodep;