#size-cells = <1>;
setting = "sunrise ohoka";
other-node = "/some-bus/c-test@5";
+ int-values = <0x1937 72993>;
chosen-test {
compatible = "denx,u-boot-fdt-test";
reg = <9 1>;
return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path));
}
-const char *ofnode_read_chosen_string(const char *name)
+const void *ofnode_read_chosen_prop(const char *propname, int *sizep)
{
ofnode chosen_node;
chosen_node = ofnode_path("/chosen");
- return ofnode_read_string(chosen_node, name);
+ return ofnode_read_prop(chosen_node, propname, sizep);
+}
+
+const char *ofnode_read_chosen_string(const char *propname)
+{
+ return ofnode_read_chosen_prop(propname, NULL);
}
ofnode ofnode_get_chosen_node(const char *name)
{
const char *prop;
- prop = ofnode_read_chosen_string(name);
+ prop = ofnode_read_chosen_prop(name, NULL);
if (!prop)
return ofnode_null();
*/
ofnode ofnode_path(const char *path);
+/**
+ * ofnode_read_chosen_prop() - get the value of a chosen property
+ *
+ * This looks for a property within the /chosen node and returns its value
+ *
+ * @propname: Property name to look for
+ * @sizep: Returns size of property, or FDT_ERR_... error code if function
+ * returns NULL
+ * @return property value if found, else NULL
+ */
+const void *ofnode_read_chosen_prop(const char *propname, int *sizep);
+
/**
* ofnode_read_chosen_string() - get the string value of a chosen property
*
static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
{
const char *str;
+ const u32 *val;
ofnode node;
+ int size;
str = ofnode_read_chosen_string("setting");
ut_assertnonnull(str);
node = ofnode_get_chosen_node("setting");
ut_assert(!ofnode_valid(node));
+ val = ofnode_read_chosen_prop("int-values", &size);
+ ut_assertnonnull(val);
+ ut_asserteq(8, size);
+ ut_asserteq(0x1937, fdt32_to_cpu(val[0]));
+ ut_asserteq(72993, fdt32_to_cpu(val[1]));
+
return 0;
}
DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);