[Crosstoolchain-logs] [device-tree-compiler] 76/357: Allow references to labels

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:05:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.

commit c226ddcabc4272b0734d237d3aee2c21a2fe2387
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Wed Feb 7 14:29:07 2007 +1100

    Allow references to labels
    
    dtc allows nodes to have labels, which at present are just re-emitted
    as symbols at the appropriate places when using asm-mode output.  It
    also allows "references" where the notation &/path/to/node in a cell
    list will be replaced with the phandle of the referenced node.
    
    This patch extends the reference syntax to allow references to labels
    instead of just full device paths.  This allows nodes deep within the
    tree to be referenced with a shorter more convenient name.  References
    to labels are distinguished from reference to paths by the fact that
    paths must start with a /, but labels can never start with a /.
    
    Signed-off-by: David Gibson <dwg at au1.ibm.com>
    Signed-off-by: Jon Loeliger <jdl at freescale.com>
---
 livetree.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/livetree.c b/livetree.c
index 9ace56c..ede29fb 100644
--- a/livetree.c
+++ b/livetree.c
@@ -212,6 +212,24 @@ static struct node *get_node_by_path(struct node *tree, char *path)
 	return NULL;
 }
 
+static struct node *get_node_by_label(struct node *tree, const char *label)
+{
+	struct node *child, *node;
+
+	assert(label && (strlen(label) > 0));
+
+	if (tree->label && streq(tree->label, label))
+		return tree;
+
+	for_each_child(tree, child) {
+		node = get_node_by_label(child, label);
+		if (node)
+			return node;
+	}
+
+	return NULL;
+}
+
 static struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
 {
 	struct node *child, *node;	
@@ -229,6 +247,7 @@ static struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
 
 	return NULL;
 }
+
 /*
  * Tree checking functions
  */
@@ -673,9 +692,16 @@ static void apply_fixup(struct node *root, struct property *prop,
 	struct node *refnode;
 	cell_t phandle;
 
-	refnode = get_node_by_path(root, f->ref);
-	if (! refnode)
-		die("Reference to non-existent node \"%s\"\n", f->ref);
+	if (f->ref[0] == '/') {
+		/* Reference to full path */
+		refnode = get_node_by_path(root, f->ref);
+		if (! refnode)
+			die("Reference to non-existent node \"%s\"\n", f->ref);
+	} else {
+		refnode = get_node_by_label(root, f->ref);
+		if (! refnode)
+			die("Reference to non-existent node label \"%s\"\n", f->ref);
+	}
 
 	phandle = get_node_phandle(root, refnode);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list