summaryrefslogtreecommitdiff
path: root/checks.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2008-11-07 12:49:44 +1100
committerJon Loeliger <jdl@jdl.com>2008-11-17 14:05:48 -0600
commit9878f30f311cb56d1ab1914670b38672476916ac (patch)
treeeaf9831ff5e4a69255776bccf0c0c20204c2f683 /checks.c
parent2f766233c2189481b4ee36c99410e559f1c9158c (diff)
downloaddevice-tree-compiler-9878f30f311cb56d1ab1914670b38672476916ac.tar.gz
dtc: Handle linux,phandle properties which self-reference
Currently, dtc will generate phandles for nodes which are referenced elsewhere in the tree. phandles can also be explicitly assigned by defining the linux,phandle property. However, there is no way, currently to tell dtc to generate a phandle for a node if it is not referenced elsewhere. This is inconvenient when it's expected that later processing on the flat tree might add nodes which _will_ the node in question. One way one might attempt to do this is with the construct: mynode: mynode { linux,phandle = <&mynode>; /* ... */ }; Though it's a trifle odd, there's really only one sensible meaning which can be assigned to this construct: allocate a unique phandle to "mynode" and put that in its linux,phandle property (as always). Currently, however, dtc will choke on this self-reference. This patch corrects this, making the construct above give the expected results. It also ensures a more meaningful error message is given if you attempt to process the nonsensical construct: mynode: mynode { linux,phandle = <&someothernode>; /* ... */ }; The 'references' testcase is extended to cover this case, as well. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'checks.c')
-rw-r--r--checks.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/checks.c b/checks.c
index 9548579..35141f9 100644
--- a/checks.c
+++ b/checks.c
@@ -282,6 +282,7 @@ static void check_explicit_phandles(struct check *c, struct node *root,
struct node *node)
{
struct property *prop;
+ struct marker *m;
struct node *other;
cell_t phandle;
@@ -295,6 +296,23 @@ static void check_explicit_phandles(struct check *c, struct node *root,
return;
}
+ m = prop->val.markers;
+ for_each_marker_of_type(m, REF_PHANDLE) {
+ assert(m->offset == 0);
+ if (node != get_node_by_ref(root, m->ref))
+ /* "Set this node's phandle equal to some
+ * other node's phandle". That's nonsensical
+ * by construction. */
+ FAIL(c, "linux,phandle in %s is a reference to another node",
+ node->fullpath);
+ /* But setting this node's phandle equal to its own
+ * phandle is allowed - that means allocate a unique
+ * phandle for this node, even if it's not otherwise
+ * referenced. The value will be filled in later, so
+ * no further checking for now. */
+ return;
+ }
+
phandle = propval_cell(prop);
if ((phandle == 0) || (phandle == -1)) {
FAIL(c, "%s has invalid linux,phandle value 0x%x",