From owner-svn-src-head@FreeBSD.ORG Mon Jun 17 15:34:23 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B54529C7; Mon, 17 Jun 2013 15:34:23 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8ED4A1E37; Mon, 17 Jun 2013 15:34:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5HFYNkO036118; Mon, 17 Jun 2013 15:34:23 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5HFYNk9036116; Mon, 17 Jun 2013 15:34:23 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201306171534.r5HFYNk9036116@svn.freebsd.org> From: David Chisnall Date: Mon, 17 Jun 2013 15:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251856 - head/usr.bin/dtc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jun 2013 15:34:23 -0000 Author: theraven Date: Mon Jun 17 15:34:22 2013 New Revision: 251856 URL: http://svnweb.freebsd.org/changeset/base/251856 Log: Add a checker to dtc, based on a feature request from rwatson / brooks. This checks that every node that has children specifies their register sizes. This is not enabled by default, as the default sizes are sometimes required (including by some DTS in the tree), but can help when writing new device trees so that you can check that you actually meant the defaults. Modified: head/usr.bin/dtc/checking.cc head/usr.bin/dtc/dtc.1 Modified: head/usr.bin/dtc/checking.cc ============================================================================== --- head/usr.bin/dtc/checking.cc Mon Jun 17 15:30:47 2013 (r251855) +++ head/usr.bin/dtc/checking.cc Mon Jun 17 15:34:22 2013 (r251856) @@ -33,6 +33,8 @@ #include "checking.hh" #include + + 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( "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 Modified: head/usr.bin/dtc/dtc.1 ============================================================================== --- head/usr.bin/dtc/dtc.1 Mon Jun 17 15:30:47 2013 (r251855) +++ head/usr.bin/dtc/dtc.1 Mon Jun 17 15:34:22 2013 (r251856) @@ -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: