libfdt: Add functions for handling the "compatible" property
This patch adds functions for dealing with the compatible property. fdt_node_check_compatible() can be used to determine whether a node is compatible with a given string and fdt_node_offset_by_compatible() locates nodes with a given compatible string. Testcases for these functions are also included. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
committed by
Jon Loeliger
parent
121acdec91
commit
333542fabf
@@ -72,18 +72,23 @@ int main(int argc, char *argv[])
|
||||
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_1, TEST_SIZE_1));
|
||||
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2));
|
||||
|
||||
CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1"));
|
||||
CHECK(fdt_setprop_typed(fdt, 0, "prop-int", TEST_VALUE_1));
|
||||
CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
|
||||
|
||||
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
|
||||
CHECK(fdt_setprop_string(fdt, offset, "compatible", "subnode1"));
|
||||
CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
|
||||
OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode"));
|
||||
CHECK(fdt_setprop(fdt, offset, "compatible",
|
||||
"subsubnode1\0subsubnode", 23));
|
||||
CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
|
||||
|
||||
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2"));
|
||||
CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
|
||||
OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode@0"));
|
||||
|
||||
CHECK(fdt_setprop(fdt, offset, "compatible",
|
||||
"subsubnode2\0subsubnode", 23));
|
||||
CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
|
||||
|
||||
CHECK(fdt_pack(fdt));
|
||||
|
||||
Reference in New Issue
Block a user