summaryrefslogtreecommitdiff
path: root/usr.bin/dtc
diff options
context:
space:
mode:
authorDavid Chisnall <theraven@FreeBSD.org>2013-06-17 15:34:22 +0000
committerDavid Chisnall <theraven@FreeBSD.org>2013-06-17 15:34:22 +0000
commite29c18df28d7e6c78b877228de951bcd6ab91664 (patch)
tree5c743d1e6e2bbdcb0b00464fc1555e9bf9a18534 /usr.bin/dtc
parent0f78a367ab7e5fed41a13ed63dca342d01a312e1 (diff)
downloadsrc-test2-e29c18df28d7e6c78b877228de951bcd6ab91664.tar.gz
src-test2-e29c18df28d7e6c78b877228de951bcd6ab91664.zip
Notes
Diffstat (limited to 'usr.bin/dtc')
-rw-r--r--usr.bin/dtc/checking.cc52
-rw-r--r--usr.bin/dtc/dtc.16
2 files changed, 58 insertions, 0 deletions
diff --git a/usr.bin/dtc/checking.cc b/usr.bin/dtc/checking.cc
index 5462a494f888..ac417eb0613d 100644
--- a/usr.bin/dtc/checking.cc
+++ b/usr.bin/dtc/checking.cc
@@ -33,6 +33,8 @@
#include "checking.hh"
#include <stdio.h>
+
+
namespace dtc
{
namespace fdt
@@ -40,6 +42,54 @@ namespace fdt
namespace checking
{
+namespace
+{
+ /**
+ * Checker that verifies that every node that has children has
+ * #address-cells and #size-cells properties.
+ */
+ struct address_cells_checker : public checker
+ {
+ address_cells_checker(const char *name) : checker(name) {}
+ virtual bool check_node(device_tree *tree, node *n)
+ {
+ // If this has no children, it trivially meets the
+ // conditions.
+ if (n->child_begin() == n->child_end())
+ {
+ return true;
+ }
+ bool found_address = false;
+ bool found_size = false;
+ for (node::property_iterator i=n->property_begin(),
+ e=n->property_end() ; i!=e ; ++i)
+ {
+ if (!found_address)
+ {
+ found_address = ((*i)->get_key() == "#address-cells");
+ }
+ if (!found_size)
+ {
+ found_size = ((*i)->get_key() == "#size-cells");
+ }
+ if (found_size && found_address)
+ {
+ break;
+ }
+ }
+ if (!found_address)
+ {
+ report_error("Missing #address-cells property");
+ }
+ if (!found_size)
+ {
+ report_error("Missing #size-cells property");
+ }
+ return found_address && found_size;
+ }
+ };
+} // anonymous namespace
+
bool
checker::visit_node(device_tree *tree, node *n)
{
@@ -157,6 +207,8 @@ check_manager::check_manager()
add_property_type_checker<property_value::STRING>(
"type-model", string("model"));
add_property_size_checker("type-phandle", string("phandle"), 4);
+ disabled_checkers.insert(std::make_pair(string("cells-attributes"),
+ new address_cells_checker("cells-attributes")));
}
bool
diff --git a/usr.bin/dtc/dtc.1 b/usr.bin/dtc/dtc.1
index 567aa03ef10d..97247876c754 100644
--- a/usr.bin/dtc/dtc.1
+++ b/usr.bin/dtc/dtc.1
@@ -214,6 +214,12 @@ property.
Checks the type of the
.Va compatible
property.
+.It cells-attributes
+Checks that all nodes with children have both
+.Va #address-cells
+and
+.Va #size-cells
+properties.
.El
.Sh EXAMPLES
The command: