浏览代码

fdt: Add function to read boolean property

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>
Gabe Black 12 年之前
父节点
当前提交
79289c0b5f
共有 2 个文件被更改,包括 24 次插入0 次删除
  1. 10 0
      include/fdtdec.h
  2. 14 0
      lib/fdtdec.c

+ 10 - 0
include/fdtdec.h

@@ -398,6 +398,16 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
 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.

+ 14 - 0
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;